-
Notifications
You must be signed in to change notification settings - Fork 208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table types #2646
Comments
Oh yes, of course. It's a relation after all - an array of tuples. This proposal does not introduce anything new, just says that any relational variables without values should be treated as database tables. |
Great! Actually one more question — just the syntax: should the items be type definitions rather than
|
I'd say no. That's because this is an array of a single tuple:
... the tuple fields are "a set of all ints" and "a set of all strings and the null value", but it's a normal variable nonetheless. It's converted into a type only when
|
OK, I'm trying to build a mental model of this. The tuple's values are types, which give us the constraint of "a set of all ints" etc... If so, I might have thought these would be equivalent:
and
...but my mental model is still a bit hazy. |
This is the key concept: sets are values that can be converted to types, using
This is possible because there a bit of overlap between "normal values" and "values that can be converted into types". In this case, I leveraged the fact that literals can be converted into a singleton type (a type that can hold only one value). So |
Update: with #3786 we have separate grammars for types and expressions. This means my last comment is not relevant anymore and we can change the syntax of table declarations separately from the the grammar of value expressions. For clarity there are a few more examples: ## a tuple type
type my_tuple = {id = int, b = string || null}
## a relational type
type my_relation = [my_tuple]
## equivalent to the above
type my_relation = [{id = int, b = string || null}]
## a table declaration
## We don't provide the value, only a relational type,
## so the compiler can assume that this variable exists
## as a table in the target database.
let my_table <my_relation>
## equivalent
let my_table <[my_tuple]>
## equivalent, again
let my_table <[{id = int, b = string || null}]> |
What's up?
In #2622 (comment), @aljazerzen makes an interesting suggestion re declaring tables. I'm moving here so we can keep that focused on the nulls question.
I quite like this!
Only one question — should it be an array of these? e.g.
The text was updated successfully, but these errors were encountered: