question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SQL name resolution

See original GitHub issue

For 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:closed
  • Created a year ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
elpranscommented, Oct 17, 2022

Yeah, I’d avoid adding suffixes and prefixes to names unless absolutely necessary.

0reactions
msullivancommented, Oct 18, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

PL/SQL Name Resolution - Database - Oracle Help Center
This appendix explains PL/SQL name resolution; that is, how the PL/SQL compiler resolves ambiguous references to identifiers.
Read more >
SQL Server Name Resolution Troubleshooting
The first and easiest way to check name resolution is to PING the host using only the hostname if you're local to the...
Read more >
Name Resolution | CockroachDB Docs
Name resolution occurs separately to look up existing objects and to decide the full name of a new object. The rules to look...
Read more >
Gotchas with Deferred Name Resolution in SQL Server
Deferred Name Resolution allows you to create objects in SQL Server without verifying that referenced objects (or referenced columns in objects) ...
Read more >
Object Name Resolution - Snowflake Documentation
This topic describes how schema object names are resolved. ... mostly for compatibility with other systems, such as Microsoft SQL Server and IBM...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found