You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The default generateIdentifierType generates Identifiers like this:
/** Identifier type for Product */exporttypeProductId=number&{__brand: 'ProductId'};
When using multiple schemas, it's is possible that two schemas will contain tables with the same name. To make the Identifier more strict, it probably should include the schema name as well.
Such as:
/** Identifier type for Public.Product */exporttypeProductId=number&{__brand: 'Public.ProductId '};
I worked around this issue by implementing a custom generateIdentifierType function like so:
// generate Schema Aware IdentifiersfunctiongenerateIdentifierType(column,details){return{declarationType: 'typeDeclaration',name: pascalCase(`${details.name}_${column.name}`),exportAs: 'named',typeDefinition: [`number & { __brand: '${details.schemaName}.${details.name}.${column.name}' }`,],comment: [`Identifier type for ${details.schemaName}.${details.name}`],}}
This creates something like this:
// In `term_life/Product.ts`/** Identifier type for term_life.product */exporttypeProductId=number&{__flavor?: 'term_life.product.id'};// In `income_protection/Product.ts`/** Identifier type for income_protection.product */exporttypeProductId=number&{__flavor?: 'income_protection.product.id'};
The text was updated successfully, but these errors were encountered:
aq1018
changed the title
kanel should provide options for schema aware Identifiers
kanel schema aware Identifiers
Jul 18, 2024
The default
generateIdentifierType
generates Identifiers like this:When using multiple schemas, it's is possible that two schemas will contain tables with the same name. To make the Identifier more strict, it probably should include the schema name as well.
Such as:
I worked around this issue by implementing a custom
generateIdentifierType
function like so:This creates something like this:
The text was updated successfully, but these errors were encountered: