getTableSchemeImpl method
TableScheme?
getTableSchemeImpl(
- String table,
- TableRelationshipReference? relationship, {
- Object? contextID,
inherited
Implementation that returns a TableScheme for table.
contextIDshould be Expando compatible. It informs that other calls to getTableSchemeImpl are in the same context and could have shared internal caches for the samecontextIDinstance.
Implementation
@override
TableScheme? getTableSchemeImpl(
String table,
TableRelationshipReference? relationship, {
Object? contextID,
}) {
var tableScheme = tablesSchemes[table];
if (tableScheme != null) return tableScheme;
var entityHandler = getEntityHandler(tableName: table);
if (entityHandler == null) {
// A relationship table has no entity: its scheme is the 2 ID fields
// (source and target) of the relationship.
if (relationship != null) {
var sourceId =
'${relationship.sourceTable}_${relationship.sourceField}';
var targetId =
'${relationship.targetTable}_${relationship.targetField}';
tableScheme = TableScheme(
table,
relationship: true,
idFieldName: sourceId,
fieldsTypes: {
sourceId: relationship.sourceFieldType,
targetId: relationship.targetFieldType,
},
);
adapterLogger.info('relationship> $tableScheme');
return tableScheme;
}
throw StateError(
"Can't resolve `TableScheme` for table `$table`. No `EntityHandler` found for table `$table`!",
);
}
var idFieldName = entityHandler.idFieldName();
var entityFieldsTypes = entityHandler.fieldsTypes();
var fieldsTypes = entityFieldsTypes.map(
(key, value) => MapEntry(key, value.type),
);
tableScheme = TableScheme(
table,
relationship: relationship != null,
idFieldName: idFieldName,
fieldsTypes: fieldsTypes,
);
adapterLogger.info('$tableScheme');
return tableScheme;
}