DBSQLMemoryAdapter class

A DBSQLAdapter that stores tables data in memory.

Simulates a SQL Database adapter. Useful for tests and development.

Inheritance
Implemented types
Available extensions

Constructors

DBSQLMemoryAdapter({bool generateTables = false, bool checkTables = true, Object? populateTables, Object? populateSource, Object? populateSourceVariables, EntityRepositoryProvider? parentRepositoryProvider, String? workingPath, bool logSQL = false})

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
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
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<DBSQLMemoryAdapterContext>>
On close events.
latefinalinherited
parentRepositoryProvider EntityRepositoryProvider?
finalinherited
poolAliveElementsSize int
no setterinherited
poolCreatedElementsCount int
no setterinherited
poolDisposedElementsCount int
no setterinherited
poolElements Iterable<DBSQLMemoryAdapterContext>
no setterinherited
poolFullWaitTimeout Duration
no setterinherited
poolFullYieldTimeout Duration
no setterinherited
poolSize int
no setterinherited
poolSizeDesiredLimit int
no setterinherited
poolYieldTimeout Duration
no setterinherited
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
tablesIndexesVersions Map<String, Map<String, int>>
no setter
tablesSchemes Map<String, TableScheme>
final
tablesVersions Map<String, int>
no setter
throwTransactionResultWithError bool
no setteroverride

Methods

addTableSchemes(Iterable<TableScheme> tablesSchemes) → void
allRepositories({Map<Type, EntityRepository<Object>>? allRepositories, Set<EntityRepositoryProvider>? traversedProviders}) Map<Type, EntityRepository<Object>>
inherited
callCheckPool() FutureOr<bool>
inherited
cancelTransaction(Transaction transaction, DBSQLMemoryAdapterContext? connection, Object? error, StackTrace? stackTrace) bool
override
catchFromPool({Duration? timeout}) DBSQLMemoryAdapterContext
catchFromPopulatedPool() FutureOr<DBSQLMemoryAdapterContext?>
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
override
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
override
closeConnection(DBSQLMemoryAdapterContext connection) bool
override
closePoolElement(DBSQLMemoryAdapterContext o) FutureOr<bool>
Defaults: calls closeConnection.
inherited
closeTransaction(Transaction transaction, DBSQLMemoryAdapterContext? connection) FutureOr<void>
override
countSQL(TransactionOperation op, String entityName, String table, SQL sql) FutureOr<int>
inherited
createConnection() DBSQLMemoryAdapterContext
Creates a connection C for this adapte
override
createPoolElement({bool force = false}) FutureOr<DBSQLMemoryAdapterContext?>
Defaults: calls createConnection.
inherited
createPoolElementForced() FutureOr<DBSQLMemoryAdapterContext>
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(DBSQLMemoryAdapterContext 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, DBSQLMemoryAdapterContext 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, DBSQLMemoryAdapterContext 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, DBSQLMemoryAdapterContext 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, DBSQLMemoryAdapterContext connection) FutureOr
override
doInsertSQL(String entityName, String table, SQL sql, Transaction transaction, DBSQLMemoryAdapterContext 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, DBSQLMemoryAdapterContext 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, DBSQLMemoryAdapterContext 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(DBSQLMemoryAdapterContext connection)) FutureOr<R>
inherited
executeWithPool<R>(FutureOr<R> f(DBSQLMemoryAdapterContext o), {Duration? timeout, bool validator(DBSQLMemoryAdapterContext 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(DBSQLMemoryAdapterContext o)) FutureOr<List<DBSQLMemoryAdapterContext>>
inherited
foreignKeyTypeToSQLType(TypeInfo idType, String idName, {List<EntityField>? entityFieldAnnotations}) String?
inherited
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(DBSQLMemoryAdapterContext 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) FutureOr<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}) TableScheme?
Returns a TableScheme for table. Calls getTableSchemeImpl handling asynchronous calls.
override
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}) 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>
override
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<DBSQLMemoryAdapterContext>>
inherited
isConnectionValid(DBSQLMemoryAdapterContext connection, {bool checkUsage = true}) FutureOr<bool>
Returns true if connection is valid for usage.
override
isPoolElementInvalid(DBSQLMemoryAdapterContext o, {bool checkUsage = true}) FutureOr<bool>
inherited
isPoolElementValid(DBSQLMemoryAdapterContext o, {bool checkUsage = true}) FutureOr<bool>
Defaults: calls isConnectionValid.
inherited
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
nextID(String table) Object
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) DBSQLMemoryAdapterContext
override
parseIDs<I extends Object>(Iterable ids) List<I>
inherited
peekFromPool() FutureOr<DBSQLMemoryAdapterContext?>
inherited
populateImpl() FutureOr<InitializationResult>
inherited
populateTables(Object? tables) FutureOr<List<String>>
inherited
populateTablesFromSQLs(String sqls) FutureOr<List<String>>
inherited
preparePoolElement(DBSQLMemoryAdapterContext o) FutureOr<DBSQLMemoryAdapterContext?>
inherited
primaryKeyTypeToSQLType(Type type, {List<EntityField>? entityFieldAnnotations}) String?
inherited
recyclePoolElement(DBSQLMemoryAdapterContext o) FutureOr<DBSQLMemoryAdapterContext?>
inherited
registerEntityRepository<O extends Object>(EntityRepository<O> entityRepository) → void
inherited
releaseIntoPool(DBSQLMemoryAdapterContext o) FutureOr<bool>
inherited
removeElementsFromPool(int amount) int
inherited
removeFromPool(DBSQLMemoryAdapterContext o) bool
inherited
removeInvalidElementsFromPool({bool checkUsage = true}) FutureOr<bool>
inherited
resolveError(Object error, StackTrace stackTrace, Object? operation, Object? previousError) Object
override
resolveTransactionResult(dynamic result, Transaction transaction, DBSQLMemoryAdapterContext? connection) FutureOr
override
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
toString() String
A string representation of this object.
override
typeToSQLType(TypeInfo type, String column, {List<EntityField>? entityFieldAnnotations}) String?
inherited
updateSQL(TransactionOperation op, String entityName, String table, SQL sql, Object id, Map<String, Object?> fields, {bool allowAutoInsert = false}) FutureOr
inherited
validPoolElements() FutureOr<List<DBSQLMemoryAdapterContext>>
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
fromConfig(Map<String, dynamic>? config, {EntityRepositoryProvider? parentRepositoryProvider, String? workingPath}) FutureOr<DBSQLMemoryAdapter>
override