DBMySQLAdapter class

A MySQL adapter.

Inheritance
Implemented types
Available extensions

Constructors

DBMySQLAdapter(String databaseName, String username, {String? host = 'localhost', Object? password, PasswordProvider? passwordProvider, int? port = 3306, int minConnections = 1, int maxConnections = 3, bool generateTables = false, bool checkTables = true, Object? populateTables, Object? populateSource, Object? populateSourceVariables, EntityRepositoryProvider? parentRepositoryProvider, String? workingPath, bool logSQL = false})
DBMySQLAdapter.fromConfig(Map<String, dynamic>? config, {String? defaultDatabase, String? defaultUsername, String? defaultHost, int? defaultPort, int? minConnections, int? maxConnections, EntityRepositoryProvider? parentRepositoryProvider, String? workingPath})
factory

Properties

callCloseTransactionRequired bool
no setteroverride
cancelTransactionResultWithError bool
no setteroverride
capability DBSQLAdapterCapability
The DBSQLAdapter capability.
no setterinherited
checkedTables bool
Return true if DB tables where successfully checked.
no setterinherited
connectionInactivityLimit Duration
The maximum allowed duration of inactivity for a connection in the pool. Default: 15min
getter/setter pairinherited
databaseName String
final
dialect SQLDialect
The DB dialect of this adapter.
no setteroverride
dialectName String
The DB dialect name of this adapter.
no setterinherited
entityRepositories List<EntityRepository<Object>>
no setterinherited
entityRepositoriesBuildOrder List<EntityRepository<Object>>
no setterinherited
generatedTables bool
Return true if DB tables where successfully generated.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
host String
final
initializationStatus InitializationStatus
Returns the current InitializationStatus.
no setterinherited
instanceID int
finalinherited
isAsyncInitialization bool
Returns true if this instance initialization was asynchronous.
no setterinherited
isClosed bool
no setterinherited
isInitialized bool
Returns true if this instance is already initialized.
no setterinherited
isInitializing bool
Returns true if this instance is in the middle of the initialization process.
no setterinherited
isPoolEmpty bool
no setterinherited
isPoolNotEmpty bool
no setterinherited
lastCheckPoolElapsedTimeMs int
no setterinherited
logSQL bool
finalinherited
maxConnections int
The maximum number of connections in the pool of this adapter.
finalinherited
minConnections int
The minimum number of connections in the pool of this adapter.
finalinherited
name String
The name of the adapter.
finalinherited
onClose Stream<DBAdapter<DBMySqlConnectionWrapper>>
On close events.
latefinalinherited
parentRepositoryProvider EntityRepositoryProvider?
finalinherited
poolAliveElementsSize int
no setterinherited
poolCreatedElementsCount int
no setterinherited
poolDisposedElementsCount int
no setterinherited
poolElements Iterable<DBMySqlConnectionWrapper>
no setterinherited
poolFullWaitTimeout Duration
no setterinherited
poolFullYieldTimeout Duration
no setterinherited
poolSize int
no setterinherited
poolSizeDesiredLimit int
no setterinherited
poolYieldTimeout Duration
no setterinherited
port int
final
registeredEntityRepositories List<EntityRepository<Object>>
no setterinherited
registeredEntityRepositoriesInformation Map<EntityRepository<Object>, Object>
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
runtimeTypeNameSafe String
Returns the runtimeType as String in safe way.
no setteroverride
throwTransactionResultWithError bool
no setteroverride
username String
final

Methods

allRepositories({Map<Type, EntityRepository<Object>>? allRepositories, Set<EntityRepositoryProvider>? traversedProviders}) Map<Type, EntityRepository<Object>>
inherited
callCheckPool() FutureOr<bool>
inherited
cancelTransaction(Transaction transaction, DBMySqlConnectionWrapper? connection, Object? error, StackTrace? stackTrace) bool
override
catchFromPool({Duration? timeout}) FutureOr<DBMySqlConnectionWrapper>
inherited
catchFromPopulatedPool() FutureOr<DBMySqlConnectionWrapper?>
inherited
checkConnections() FutureOr<bool>
Checks the connections of the pool. Defaults: calls removeInvalidElementsFromPool.
inherited
checkDB() FutureOr<bool>
inherited
checkDBTableField(Type entityType, String fieldName, Type? schemeType, TypeInfo? fieldType) bool
inherited
checkDBTables() FutureOr<bool>
inherited
checkEntityFields<O>(O o, String entityName, String table, {EntityHandler<O>? entityHandler}) → void
inherited
checkInitialized() → void
Checks if this instance is initialized.
inherited
checkNotClosed() → void
inherited
checkPool() FutureOr<bool>
Checks the pool connections and limits.
inherited
checkPoolSize(int minSize, int maxSize, int checkInvalidsIntervalMs) FutureOr<bool>
inherited
clearPool() FutureOr<bool>
inherited
close() bool
inherited
closeConnection(DBMySqlConnectionWrapper connection) bool
override
closePoolElement(DBMySqlConnectionWrapper o) FutureOr<bool>
Defaults: calls closeConnection.
inherited
closeTransaction(Transaction transaction, DBMySqlConnectionWrapper? connection) FutureOr<void>
override
countSQL(TransactionOperation op, String entityName, String table, SQL sql) FutureOr<int>
inherited
createConnection() FutureOr<DBMySqlConnectionWrapper>
Creates a connection C for this adapte
override
createPoolElement({bool force = false}) FutureOr<DBMySqlConnectionWrapper?>
Defaults: calls createConnection.
inherited
createPoolElementForced() FutureOr<DBMySqlConnectionWrapper>
inherited
createRepositoryAdapter<O>(String name, {String? tableName, Type? type}) DBSQLRepositoryAdapter<O>?
inherited
deleteSQL(TransactionOperation op, String entityName, String table, SQL sql) FutureOr<Iterable<Map<String, dynamic>>>
inherited
disposePoolElement(DBMySqlConnectionWrapper o) FutureOr<bool>
inherited
disposeTableSchemeCache(String table) TableScheme?
Disposes a TableScheme for table. Forces refresh of previous scheme.
inherited
doCount(TransactionOperation op, String entityName, String table, {EntityMatcher? matcher, Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters, PreFinishDBOperation<int, int>? preFinish}) FutureOr<int>
inherited
doCountSQL(String entityName, String table, SQL sql, Transaction transaction, DBMySqlConnectionWrapper connection) FutureOr<int>
override
doDelete<R>(TransactionOperation op, String entityName, String table, EntityMatcher matcher, {Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters, PreFinishDBOperation<Iterable<Map<String, dynamic>>, R>? preFinish}) FutureOr<R>
inherited
doDeleteSQL(String entityName, String table, SQL sql, Transaction transaction, DBMySqlConnectionWrapper connection) FutureOr<Iterable<Map<String, dynamic>>>
override
doExistIDs<I extends Object>(TransactionOperation op, String entityName, String table, List<I> ids) FutureOr<List<I>>
inherited
doExistIDsSQL<I extends Object>(String entityName, String table, SQL sql, Transaction transaction, DBMySqlConnectionWrapper connection) FutureOr<List<I>>
override
doInitialization({Initializable? parent}) FutureOr<InitializationResult>
Initialize this instance if is not initialized yet.
inherited
doInsert<O>(TransactionOperation op, String entityName, String table, O o, Map<String, dynamic> fields, {String? idFieldName, PreFinishDBOperation? preFinish}) FutureOr
inherited
doInsertRelationship(TransactionOperation op, String entityName, String table, String field, dynamic id, String otherTableName, List otherIds, [PreFinishDBOperation<bool, bool>? preFinish]) FutureOr<bool>
inherited
doInsertRelationshipSQL(String entityName, String table, SQL sql, Transaction transaction, DBMySqlConnectionWrapper connection) FutureOr
inherited
doInsertSQL(String entityName, String table, SQL sql, Transaction transaction, DBMySqlConnectionWrapper connection) FutureOr
override
doSelect<R>(TransactionOperation op, String entityName, String table, EntityMatcher matcher, {Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters, int? limit, PreFinishDBOperation<Iterable<Map<String, dynamic>>, R>? preFinish}) FutureOr<R>
inherited
doSelectAll<R>(TransactionOperation op, String entityName, String table, {PreFinishDBOperation<Iterable<Map<String, dynamic>>, List<R>>? preFinish}) FutureOr<List<R>>
inherited
doSelectByID<R>(TransactionOperation op, String entityName, String table, Object id, {PreFinishDBOperation<Map<String, dynamic>?, R?>? preFinish}) FutureOr<R?>
inherited
doSelectByIDs<R>(TransactionOperation op, String entityName, String table, List<Object> ids, {PreFinishDBOperation<Iterable<Map<String, dynamic>>, List<R>>? preFinish}) FutureOr<List<R>>
inherited
doSelectIDsBy<I extends Object>(TransactionOperation op, String entityName, String table, EntityMatcher matcher, {Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters, int? limit}) FutureOr<List<I>>
inherited
doSelectRelationship<R>(TransactionOperation op, String entityName, String table, String field, dynamic id, String otherTableName, [PreFinishDBOperation<Iterable<Map<String, dynamic>>, R>? preFinish]) FutureOr<R>
inherited
doSelectRelationships<R>(TransactionOperation op, String entityName, String table, String field, List ids, String otherTableName, [PreFinishDBOperation<Iterable<Map<String, dynamic>>, R>? preFinish]) FutureOr<R>
inherited
doSelectSQL(String entityName, String table, SQL sql, Transaction transaction, DBMySqlConnectionWrapper connection) FutureOr<Iterable<Map<String, dynamic>>>
override
doUpdate<O>(TransactionOperation op, String entityName, String table, O o, Object id, Map<String, dynamic> fields, {String? idFieldName, PreFinishDBOperation? preFinish, bool allowAutoInsert = false}) FutureOr
inherited
doUpdateSQL(String entityName, String table, SQL sql, Object id, Transaction transaction, DBMySqlConnectionWrapper connection, {bool allowAutoInsert = false}) FutureOr
override
ensureInitialized({Initializable? parent}) FutureOr<InitializationResult>
Ensures that this instance is initialized.
inherited
ensureInitializedAsync({Initializable? parent}) FutureOr<InitializationResult>
Ensures that this instance is initialized. If is not initialized yet it will force an asynchronous initialization and return a Future.
inherited
entityTypeToSQLType(TypeInfo type, String? column, {List<EntityField>? entityFieldAnnotations}) MapEntry<String, MapEntry<String, String>>?
Returns info for the column: table -> idName: sqlType
inherited
enumTypeToSQLType(Type type, String column, {List<EntityField>? entityFieldAnnotations}) MapEntry<String, List<String>>?
Returns: ENUM: valuesNames
inherited
executeInitialized<R>(ExecuteInitializedCallback<R> callback, {Initializable? parent}) FutureOr<R>
Executes the callback ensuring that this instances was fully initialized.
inherited
executeTableSQL(String createTableSQL) FutureOr<bool>
override
executeTransactionOperation<R>(TransactionOperation op, SQLWrapper sql, FutureOr<R> f(DBMySqlConnectionWrapper connection)) FutureOr<R>
inherited
executeWithPool<R>(FutureOr<R> f(DBMySqlConnectionWrapper o), {Duration? timeout, bool validator(DBMySqlConnectionWrapper o)?, dynamic onError(Object error, StackTrace stackTrace)?}) FutureOr<R>
inherited
existIDsSQL<I extends Object>(TransactionOperation op, String entityName, String table, SQL sql) FutureOr<List<I>>
inherited
fieldValueToSQL(EncodingContext context, TableScheme tableScheme, String fieldName, Object? value, Map<String, Object?> fieldsValues) FutureOr<String>
inherited
filterPoolElements(FutureOr<bool> filter(DBMySqlConnectionWrapper o)) FutureOr<List<DBMySqlConnectionWrapper>>
inherited
foreignKeyTypeToSQLType(TypeInfo idType, String idName, {List<EntityField>? entityFieldAnnotations}) String?
override
generateAddColumnAlterTableSQL(String table, String fieldName, TypeInfo fieldType, {List<EntityField>? entityFieldAnnotations}) AlterTableSQL
inherited
generateAddEnumConstraintAlterTableSQL(String table, String fieldName, TypeInfo fieldType, {List<EntityField>? entityFieldAnnotations}) AlterTableSQL
inherited
generateAddUniqueConstraintAlterTableSQL(String table, String fieldName, TypeInfo fieldType, {List<EntityField>? entityFieldAnnotations}) AlterTableSQL
inherited
generateCountSQL(Transaction transaction, String entityName, String table, {EntityMatcher? matcher, Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters}) FutureOr<SQL>
inherited
generateCreateTableSQL({EntityRepository<Object>? entityRepository, Object? obj, Type? type, String? name, String? tableName, bool ifNotExists = true, bool sortColumns = true}) CreateTableSQL
inherited
generateCreateTableSQLs({bool ifNotExists = true, bool sortColumns = true}) List<SQLBuilder>
Generate all the SQLs to create the tables.
inherited
generateDeleteSQL(Transaction transaction, String entityName, String table, EntityMatcher matcher, {Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters}) FutureOr<SQL>
inherited
generateEntityRepositoresCreateTableSQLs({bool ifNotExists = true, bool sortColumns = true, bool verbose = false}) Map<EntityRepository<Object>, CreateTableSQL>
Generates the CreateTableSQL for each EntityRepository. See entityRepositories.
inherited
generateExistIDsSQL<I extends Object>(Transaction transaction, String entityName, String table, List<I> ids) FutureOr<SQL>
inherited
generateFullCreateTableSQLs({String? title, bool withDate = true, bool ifNotExists = true, bool sortColumns = true}) Future<String>
Generate a full text with all the SQLs to create the tables.
inherited
generateInsertRelationshipSQLs(Transaction transaction, String entityName, String table, String field, dynamic id, String otherTableName, List otherIds) FutureOr<List<SQL>>
inherited
generateInsertSQL(Transaction transaction, String entityName, String table, Map<String, Object?> fields) FutureOr<SQL>
inherited
generateSelectIDsSQL(Transaction transaction, String entityName, String table, EntityMatcher matcher, {Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters, int? limit}) FutureOr<SQL>
inherited
generateSelectRelationshipSQL(Transaction transaction, String entityName, String table, String field, dynamic id, String otherTableName) FutureOr<SQL>
inherited
generateSelectRelationshipsSQL(Transaction transaction, String entityName, String table, String field, List ids, String otherTableName) FutureOr<SQL>
inherited
generateSelectSQL(Transaction transaction, String entityName, String table, EntityMatcher matcher, {Object? parameters, List? positionalParameters, Map<String, Object?>? namedParameters, int? limit}) FutureOr<SQL>
inherited
generateTables() FutureOr<List<String>>
inherited
generateUpdateSQL(Transaction transaction, String entityName, String table, Object id, Map<String, Object?> fields) FutureOr<SQL>
inherited
getConnectionURL(DBMySqlConnectionWrapper connection) String
Returns the URL of the connection.
override
getEntityByID<O>(dynamic id, {Type? type, bool sync = false, EntityResolutionRules? resolutionRules}) FutureOr<O?>
inherited
getEntityHandler<T>({String? entityName, String? tableName, Type? entityType}) EntityHandler<T>?
inherited
getEntityID(Object entity, {String? entityName, String? tableName, Type? entityType, EntityHandler? entityHandler}) Object?
Returns the entity ID for entityName, tableName or entityType.
inherited
getEntityRepositoresTables() FutureOr<Map<EntityRepository<Object>, String>>
inherited
getEntityRepository<O extends Object>({O? obj, Type? type, String? name, String? tableName}) EntityRepository<O>?
inherited
getEntityRepositoryByType<O extends Object>(Type type) EntityRepository<O>?
inherited
getEntityRepositoryByTypeInfo<O extends Object>(TypeInfo typeInfo) EntityRepository<O>?
inherited
getFieldType(String field, {String? entityName, String? tableName, Type? entityType}) FutureOr<TypeInfo?>
Returns the type for the field at tableName or by entityName.
inherited
getRepositoriesSchemes() Future<Map<EntityRepository<Object>, TableScheme?>>
inherited
getRepositoryAdapterByName<O>(String name) DBSQLRepositoryAdapter<O>?
inherited
getRepositoryAdapterByTableName<O>(String tableName) DBSQLRepositoryAdapter<O>?
inherited
getRepositoryAdapterByType<O>(Type type) DBSQLRepositoryAdapter<O>?
inherited
getTableFieldsTypes(String table) FutureOr<Map<String, Type>?>
Returns a TableScheme.fieldsTypes for table.
inherited
getTableFieldsTypesImpl(String table) Future<Map<String, Type>?>
override
getTableForEntityRepository(EntityRepository<Object> entityRepository) String
Returns the table name for entityRepository.
inherited
getTableForType(TypeInfo type) String?
Returns the table name for type.
inherited
getTableScheme(String table, {TableRelationshipReference? relationship, Object? contextID}) FutureOr<TableScheme?>
Returns a TableScheme for table. Calls getTableSchemeImpl handling asynchronous calls.
inherited
getTableSchemeForEntityRepository(EntityRepository<Object> entityRepository, {Object? contextID}) FutureOr<TableScheme?>
Returns a TableScheme for entityRepository.
inherited
getTableSchemeForType(TypeInfo type) FutureOr<TableScheme?>
Returns a TableScheme for type.
inherited
getTableSchemeIfLoaded(String table) TableScheme?
inherited
getTableSchemeImpl(String table, TableRelationshipReference? relationship, {Object? contextID}) Future<TableScheme?>
Implementation that returns a TableScheme for table.
override
getVarcharPreferredSize(String? column) int
Returns the preferred VARCHAR size for a column name.
inherited
information({bool extended = false, String? table}) Map<String, dynamic>
inherited
initialize() FutureOr<InitializationResult>
Initialization implementation. Do not call it directly, use doInitialization.
inherited
initializeDependencies() List<Initializable>
Return a List of Initializable instances that need to be initialized BEFORE initialize this instance.
override
insertRelationshipSQLs(TransactionOperation op, String entityName, String table, List<SQL> sqls, dynamic id, String otherTable, List otherIds) FutureOr<bool>
inherited
insertSQL(TransactionOperation op, String entityName, String table, SQL sql, Map<String, Object?> fields) FutureOr
inherited
instantiateRepositoryAdapter<O>(String name, String? tableName, Type? type) DBSQLRepositoryAdapter<O>
inherited
invalidPoolElements({bool checkUsage = true}) FutureOr<List<DBMySqlConnectionWrapper>>
inherited
isConnectionValid(DBMySqlConnectionWrapper connection, {bool checkUsage = true}) bool
Returns true if connection is valid for usage.
override
isPoolElementInvalid(DBMySqlConnectionWrapper o, {bool checkUsage = true}) FutureOr<bool>
isPoolElementValid(DBMySqlConnectionWrapper o, {bool checkUsage = true}) bool
Defaults: calls isConnectionValid.
override
isSiblingEntityType(EntityRepository<Object> tableRepository, Type columnType, {EntityRepository<Object>? columnRepository}) bool
Returns true if columnType is a sibling of the tableRepository.
inherited
isTransactionWithSingleOperation(TransactionOperation op, [SQLWrapper? sql]) bool
inherited
normalizeColumnName(String fieldName) String
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyKnownEntityRepositoryProvider(EntityRepositoryProvider provider) → void
inherited
notifyTableFieldTypes(String table, Map<String, Type> fieldsTypes) Map<String, Type>
inherited
openTransaction(Transaction transaction) Future<DBMySqlConnectionWrapper>
override
parseIDs<I extends Object>(Iterable ids) List<I>
inherited
peekFromPool() FutureOr<DBMySqlConnectionWrapper?>
inherited
populateFromSource(Object? source, {String? workingPath, EntityResolutionRules? resolutionRules, Object? variables}) FutureOr<Map<String, List<Object>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

populateImpl() FutureOr<InitializationResult>
inherited
populateTables(Object? tables) FutureOr<List<String>>
inherited
populateTablesFromSQLs(String sqls) FutureOr<List<String>>
inherited
preparePoolElement(DBMySqlConnectionWrapper o) FutureOr<DBMySqlConnectionWrapper?>
inherited
primaryKeyTypeToSQLType(Type type, {List<EntityField>? entityFieldAnnotations}) String?
inherited
recyclePoolElement(DBMySqlConnectionWrapper o) FutureOr<DBMySqlConnectionWrapper?>
inherited
registerEntityRepository<O extends Object>(EntityRepository<O> entityRepository) → void
inherited
releaseIntoPool(DBMySqlConnectionWrapper o) FutureOr<bool>
inherited
removeElementsFromPool(int amount) int
inherited
removeFromPool(DBMySqlConnectionWrapper o) bool
inherited
removeInvalidElementsFromPool({bool checkUsage = true}) FutureOr<bool>
inherited
resolveEntitiesSource(Object? source, {String? workingPath}) FutureOr<Map<String, Iterable<Map<String, dynamic>>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveEntitiesSourceVariables(Map<String, Iterable<Map<String, dynamic>>> source, Map<String, dynamic> variables) Map<String, Iterable<Map<String, dynamic>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveEntitySourceValueVariables(String key, Object? value, Map<String, dynamic> variables) Object?

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveEntitySourceVariables(Map<String, dynamic> entity, Map<String, dynamic> variables) Map<String, dynamic>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveError(Object error, StackTrace stackTrace, Object? operation, Object? previousError) Object
override
resolveSource(Object? source, {String? workingPath}) FutureOr<Map<String, dynamic>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

resolveTransactionResult(dynamic result, Transaction transaction, DBMySqlConnectionWrapper? connection) FutureOr
inherited
selectIDFieldName(String table, List<String> primaryKeyCandidates) String
Selects the ID field name from primaryKeyCandidates candidates:
inherited
selectRelationshipSQL(TransactionOperation op, String entityName, String table, SQL sql, dynamic id, String otherTable) FutureOr<Iterable<Map<String, dynamic>>>
inherited
selectRelationshipsSQL(TransactionOperation op, String entityName, String table, SQL sql, List ids, String otherTable) FutureOr<Iterable<Map<String, dynamic>>>
inherited
selectSQL(TransactionOperation op, String entityName, String table, SQL sql) FutureOr<Iterable<Map<String, dynamic>>>
inherited
storeAllFromJson(Map<String, Iterable<Map<String, dynamic>>> entries, {Transaction? transaction, EntityResolutionRules? resolutionRules, Map<String, dynamic>? variables}) FutureOr<Map<String, List<Object>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

storeAllFromJsonEncoded(String jsonEncoded, {Transaction? transaction, EntityResolutionRules? resolutionRules, Map<String, dynamic>? variables}) FutureOr<Map<String, List<Object>>>

Available on EntityRepositoryProvider, provided by the EntityRepositoryProviderExtension extension

toString() String
A string representation of this object.
override
typeToSQLType(TypeInfo type, String column, {List<EntityField>? entityFieldAnnotations}) String?
override
updateSQL(TransactionOperation op, String entityName, String table, SQL sql, Object id, Map<String, Object?> fields, {bool allowAutoInsert = false}) FutureOr
inherited
validPoolElements() FutureOr<List<DBMySqlConnectionWrapper>>
inherited
valueToSQL(Object? value) Object?
Converts value to an acceptable SQL value for the adapter.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

boot() → void
override