Skip to content
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

Unable to reference a table from another IDEA module #502

Closed
drymarau opened this issue Oct 18, 2016 · 4 comments
Closed

Unable to reference a table from another IDEA module #502

drymarau opened this issue Oct 18, 2016 · 4 comments

Comments

@drymarau
Copy link
Contributor

Let's assume the project has two modules (module A and module B), both have *.sq files in them.

Module A, User.sq:

CREATE TABLE user (
    id INTEGER NOT NULL PRIMARY KEY,
    name TEXT NOT NULL
);

Module B, Contact.sq:

CREATE TABLE contact (
    user_id INTEGER NOT NULL,
    name TEXT NOT NULL,
    surname TEXT NOT NULL,
    FOREIGN KEY(user_id) REFERENCES user(id) ON DELETE CASCADE
)

REFERENCES user(id) ON DELETE CASCADE is highlighted by the plugin with Cannot find table user message

@JakeWharton
Copy link
Collaborator

And does module B depend on module A?

On Tue, Oct 18, 2016 at 5:06 AM Dmitry Rymarev notifications@github.com
wrote:

Let's assume the project has two modules (module A and module B), both
have *.sq files in them.

Module A, User.sq:

CREATE TABLE user (
id INTEGER NOT NULL PRIMARY KEY,
name TEXT NOT NULL
);

Module B, Contact.sq:

CREATE TABLE contact (
user_id INTEGER NOT NULL,
name TEXT NOT NULL,
surname TEXT NOT NULL,
FOREIGN KEY(user_id) REFERENCES user(id) ON DELETE CASCADE
)

REFERENCES user(id) ON DELETE CASCADE is highlighted by the plugin with Cannot
find table user
message


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#502, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEWI2AlYK-0FTXNldfRBBILW7U0NTks5q1IwegaJpZM4KZi2h
.

@drymarau
Copy link
Contributor Author

Yes

@JakeWharton
Copy link
Collaborator

This will unfortunately be non-trivial to support.

On Tue, Oct 18, 2016 at 9:54 AM Dmitry Rymarev notifications@github.com
wrote:

Yes


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#502 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEdXhLLigebIps_JSrLqY2RGJBpbDks5q1M-jgaJpZM4KZi2h
.

@AlecKazakova
Copy link
Collaborator

in terms of gradle dsl current thinking is something like this:

ModuleA/build.gradle

sqldelight {
  MyDatabase {
    sourceSets = files("src/main/sqldelight")
  }
}

ModuleB/build.gradle

sqldelight {
  MyDatabase {
    sourceSets = files("src/main/sqldelight")
    dependencies {
      implementation project(":ModuleA")
    }
  }
  OtherDatabase {
    sourceSets = files("src/other/sqldelight")
  }
}

this would have tasks :ModuleB:generateMyDatabaseInterface, :ModuleB:generateOtherDatabaseInterface, and :ModuleA:generateMyDatabaseInterface

:ModuleB:generateMyDatabaseInterface would also generate its own types for the .sq files inside of ModuleA, so that it can properly generate the code to notify upstream queries that are listening.

That dependency graph will propagate to the json file the IDE plugin reads from so if you are in ModuleB/src/main/sqldelight you can reference the schema in ModuleA/src/main/sqldelight

The database name is also incorporated into the dependency, so ModuleA must have a schema named MyDatabase for ModuleB's MyDatabase to depend on ModuleA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants