Closed Skyfold closed 5 years ago
Turns out you found a null pointer dereference in the type inference algorithm. This file now generates the error "Not an entity or type: bla".
In a query Q : S -> T, for each foreign key f : A -> B in T, there must be an assignment from the FOR-bound variables of Q(B) to expressions using the FOR-bound variables of Q(A). In fact, Q(A) and Q(B) are S-instances (you can get them using the "frozen" keyword), and the foreign_keys clauses in Q must define a natural transformation Q(B) -> Q(A) (which you can also get using "frozen"), a tricky and powerful condition checked by the automated theorem prover.
This story repeats at the level of attributes, where each attribute att : A -> t in T must induce the Yoneda embedding y(t) -> Q(A), where y(t) is the "representable instance" associated with t, which consists of a single generator of type t. Fortunately, in practice attributes clauses are much more intuitive than the above description suggests.
The concept of a "frozen instance" recurs in many data models, including the relational model. It's a pretty handy idea often employed by database theorists and dating back to the 70s.
I ran into an exception (that I assume should just be an error) when playing around with the "Query" Example code. The error I get is reproduced below:
The only thing I changed was
man
tobla
in queryQ
, entityGoodMatch
, afterforeign_keys
, line 38 (foreign_keys for_man -> {bla -> m}
). I wanted to know ifman
had any special significance since it is not anattribute
nor aforeign_keys
of either schema. The code that causes the error is reproduced below:(If possible I would like to know what the identifier
man
refers to and whatforeign_keys for_man -> {man -> m}
means. I assume it is saying theforeign_keys
for_man
maps to the selected m of type Man that satisfies the where clause.)