getTableSchemeImpl method
TableScheme?
getTableSchemeImpl(
- String table,
- TableRelationshipReference? relationship, {
- Object? contextID,
override
Implementation that returns a TableScheme for table
.
contextID
should be Expando compatible. It informs that other calls to getTableSchemeImpl are in the same context and could have shared internal caches for the samecontextID
instance.
Implementation
@override
TableScheme? getTableSchemeImpl(
String table, TableRelationshipReference? relationship,
{Object? contextID}) {
//_log.info('getTableSchemeImpl> $table ; relationship: $relationship');
var tableScheme = tablesSchemes[table];
if (tableScheme != null) return tableScheme;
var entityHandler = getEntityHandler(tableName: table);
if (entityHandler == null) {
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,
});
_log.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);
_log.info('$tableScheme');
return tableScheme;
}