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

Error when FOREIGN KEY relations use different types #1138

Open
JakeWharton opened this Issue Jan 7, 2019 · 1 comment

Comments

1 participant
@JakeWharton
Copy link
Collaborator

JakeWharton commented Jan 7, 2019

CREATE TABLE foo(id INTEGER PRIMARY KEY);

CREATE TABLE bar(
  id INTEGER PRIMARY KEY,
  foo_id TEXT NOT NULL,
  FOREIGN KEY foo_id REFERENCES foo(id)
);

@JakeWharton JakeWharton changed the title Error when FOREIGN KEY relations use different storage types Error when FOREIGN KEY relations use different types Jan 7, 2019

@JakeWharton

This comment has been minimized.

Copy link
Collaborator

JakeWharton commented Jan 7, 2019

Should work for the storage type affinity and Kotlin type affinity.

Other erroneous cases:

CREATE TABLE foo(id INTEGER PRIMARY KEY);

CREATE TABLE bar(
  id INTEGER PRIMARY KEY,
  foo_id INTEGER AS java.lang.Integer NOT NULL,
  FOREIGN KEY foo_id REFERENCES foo(id)
);
CREATE TABLE foo(id INTEGER AS java.lang.Integer PRIMARY KEY);

CREATE TABLE bar(
  id INTEGER PRIMARY KEY,
  foo_id INTEGER NOT NULL,
  FOREIGN KEY foo_id REFERENCES foo(id)
);
CREATE TABLE foo(id INTEGER AS java.lang.Integer PRIMARY KEY);

CREATE TABLE bar(
  id INTEGER PRIMARY KEY,
  foo_id INTEGER AS java.lang.Short NOT NULL,
  FOREIGN KEY foo_id REFERENCES foo(id)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment