Open Zlash92 opened 2 years ago
@AlecStrong Tried using mysql instead of postgres, but seems like an issue there as well.
Ok, I was partially mistaken. Realized that in mysql syntax the schema/database of the foreign key relation does not have to be specified (e.g., REFERENCES pld1.Person(id) can be stated without the pld1 prefix). However, in postgres this is necessary - perhaps because the public schema may be default in postgres, while in mysql it defaults to the schema of the table. Also mysql doesn't differ between schema and database like postgres does, though I'm not sure if that's quite relevant for this problem.
In the .sq file, everything is in order by omitting the schema prefix, also using postgres. So the initial problem I've stated can be bypassed.
Two reasons why it's useful to fix in the future:
yea we should definitely support this, I don't think it should be too complex to do since we can just treat the whole string pld1.Person
as the table name
just to confirm, do you also create the Person
table with the schema prefix?
like
CREATE TABLE pld1.Person (
...
);
Yep, that's correct!
SQLDelight Version
1.5.3
Operating System
macOS Big Sur 11.6.1
Gradle Version
7.3.1
Kotlin Version
1.6.0
AGP Version
No response
Describe the Bug
My postgres database contains a schema called pld1 and within this schema there are two tables Person and Car. Car references Person through a foreign key. The name of the schema is used as a prefix for the tables and foreign key. Application doesn't compile because of the schema prefix in the REFERENCES statement, even though it is valid sql. Everything works fine if the public schema is used and no schema prefix is used, but this doesn't satisfy my needs.
Stacktrace
Gradle Build Script