Reference values
Named records should be referenceable elsewhere. Creating a record should return all columns, not just those declared in the file, so they should allow the user to reference columns that are populated with database-side defaults. Additionally, references should be as ergonomic and succinct as possible.
Explicit syntaxes
Fully-qualified
The most basic (and…
Named records should be referenceable elsewhere. Creating a record should return all columns, not just those declared in the file, so they should allow the user to reference columns that are populated with database-side defaults. Additionally, references should be as ergonomic and succinct as possible.
Explicit syntaxes
Fully-qualified
The most basic (and least succinct) would be a fully-qualified syntax that explicitly lists the columns involved:
public
person
someone
likes_pizza true
-- Potential format options using `@`
_
likes_pizza [email protected]_pizza
_
likes_pizza @public.person.someone.likes_pizza
_
likes_pizza @[public.person]someone.likes_pizza
Table-qualified
The first step in reducing noise would be to allow the schema to be dropped if the tables are in the same schema:
public
person
someone
likes_pizza true
_
likes_pizza [email protected]_pizza
Unqualified
If referencing a record from the same table, both the schema and table names should be optional.
public
person
someone
likes_pizza true
_
likes_pizza @someone.likes_pizza
Implicit
It would make life easier to omit column names from the referenced value when possible.
Same column names
Potentially just allow omitting the column name completely and infer it's the same, or add some new syntax to signify that it's derived?
public
person
someone
likes_pizza true
-- Infer the column is `likes_pizza` if omitted, no matter the table the record is in?
_
likes_pizza @someone
-- Or require some distinct syntax?
_
[likes_pizza] @someone
Foreign keys
Is there a shorthand that could be useful for foreign keys? Eg:
schema1
person
leela
name 'Turanga Leela'
-- Expands to `likes_pizza #fry.likes_pizza`
[likes_pizza] #fry
pet
_
name 'Nibbler'
-- Expands to `person_id person#leela.id`
-- ... but doesn't support specifying schema
[person.id] #leela