SQL name resolution
See original GitHub issueFor the upcoming SQL support, we essentially need to implement a basic SQL name resolver. We will not support all of the SQL, but we need following features:
(using the Movies schema)
-- map Movie to our ObjectType
-- map Movie.title to the correct property
SELECT Movie.title FROM Movie;
-- figure out that property title comes from ObjectType Movie
SELECT title FROM Movie;
-- case insentive by default, lowercase when strictly-typed
SELECT tItLe, `relase_year` FROM `movie`;
-- table aliases
SELECT m.title FROM Movie AS m;
-- resolve <link>_id
SELECT title FROM Movie JOIN Genre ON Movie.genre_id = Genre.id
-- resolve <parent_type>_id
SELECT c.title, m.release_year FROM Content c JOIN Movie m ON m.content_id = c.id
-- infer subquery types
SELECT title, t.name FROM (SELECT *, title as name FROM Movie) t JOIN Genre ON ...
Inheritance
We have to decide what to do when selecting from a parent object. Should rows of child tables be included?
@1st1 says no, because SQL is low level and we should expose only this low-level data.
@msullivan says that we should at least provide some syntax to allow access to the inheriting views we already have so the SQL interface is not such a pain in the ass to use.
I think that we should avoid having two different syntaxes (or any kind of table name suffixes), because this adds much more surface for bugs and confusion.
While it would be convenient to expose inheriting views, the exposed database would not be normalized so I agree with Yury to stick only to base tables.
Names of multi-multi link tables
type Movie {
multi link actors -> Person {
property character_name -> str;
};
}
type Person {
link filmography := .<actors[is Content];
}
These tables do not have a name in EdgeQL, but need one in SQL. I suggest movie_actors_person_filmography
:
- object name where link is defined,
- link name on that object
- object name where link is referenced,
- link name on that object.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Yeah, I’d avoid adding suffixes and prefixes to names unless absolutely necessary.
Like we discussed offline, we need to duplicate pointers from parent objects in the children type–that is how we store it in edgedb, with each object in one table.
Implementation work doesn’t need to wait on a final decision on inheritance; it shouldn’t be hard to change