include entity and foreign field schema name parsing#9
Conversation
ac32a4d to
f4be66e
Compare
| | not (T.null constraintNameText) && isLower (T.head constraintNameText) = | ||
| go :: [Text] -> Maybe SchemaNameDB -> Maybe CascadeAction -> Maybe CascadeAction -> UnboundForeignDef | ||
| go (constraintNameText:rest) schemaName onDelete onUpdate | ||
| | isConstraintName = |
There was a problem hiding this comment.
Here we're a bit into the parsing of the Foreign keyword that specifies complex foreign fields (TargetEntity is already known at this point), and follows the syntax:
Foreign TargetEntity schema-name [cascade-actions] constraint-name [columns] [references]
go is structured such that it expects to terminate at constraint-name: the preceding fields (schema-name, cascade-actions - parsed below and carried through) should have already been populated, and the succeeding fields (columns, references) will be parsed/added as part of this condition.
| [childForeignDef] = | ||
| entityForeigns $ entityDef $ Proxy @ChildExplicit | ||
| it "should have a schema name defined" $ do | ||
| (foreignRefSchemaDBName childForeignDef) |
There was a problem hiding this comment.
I'd prefer to use NamedFieldPuns here but adding a pragma for a couple of lines seems excessive.
54dc83d to
5ca6374
Compare
5ca6374 to
d57084f
Compare
| fixForeignRefTableDBName = | ||
| getEntityDBName (unboundEntityDef parentDef) | ||
| fixForeignRefSchemaDBName = | ||
| getEntitySchema (unboundEntityDef parentDef) |
There was a problem hiding this comment.
Wild. We're lucky it's this easy to add in, I was wondering if it'd be a bit of a wild goose chase. Thanks!
Adding support for
schema=schema_nameto be added to Persistent entity syntax so that the quasiquoter can generate schema specifications for entities or their foreign key fields (when using the complexForeignkeyword).