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

Regression from SqlDelight 1.3.0 to 1.4.0 - Erroneous 'Multiple columns found' error #145

Closed
mhernand40 opened this issue Jul 31, 2020 · 5 comments · Fixed by #367
Closed

Comments

@mhernand40
Copy link

Dialect: SQLite

failing sql:

CREATE TABLE foo(
    id TEXT NOT NULL PRIMARY KEY
);

CREATE TABLE bar(
    id TEXT NOT NULL PRIMARY KEY
);

CREATE TABLE baz(
    id TEXT NOT NULL PRIMARY KEY
);

repro:
SELECT id FROM foo
WHERE id IN (
    SELECT foo.id FROM foo
    LEFT JOIN bar ON foo.id = bar.id
    LEFT JOIN baz ON foo.id = baz.id
);

This is a reduced repro of a more complex query that I have in my Android app, however the query above labeled repro works fine with SqlDelight 1.3.0 but when I upgrade to 1.4.0, it fails with the error message:

<path to sq files>/Foo.sq line 17:25 - Multiple columns found with name id
14    SELECT id FROM foo
15    WHERE id IN (
16        SELECT foo.id FROM foo
17        LEFT JOIN bar ON foo.id = bar.id
                               ^^
18        LEFT JOIN baz ON foo.id = baz.id
19    )

<path to sq files>/Foo.sq line 18:25 - Multiple columns found with name id
14    SELECT id FROM foo
15    WHERE id IN (
16        SELECT foo.id FROM foo
17        LEFT JOIN bar ON foo.id = bar.id
18        LEFT JOIN baz ON foo.id = baz.id
                               ^^
19    )

@mhernand40
Copy link
Author

Friendly ping on this. I am currently still stuck on SqlDelight 1.3.0 because of this. If there is a known workaround, perhaps using column aliases, I'd be open to that as well. Also, is this the correct repo to file such issues? Thanks! 🙂

@AlecKazakova
Copy link
Owner

yep this is the right repo. for a workaround I would try aliasing one of the two foo tables:

repro:
SELECT id FROM foo
WHERE id IN (
    SELECT foo.id FROM foo AS foo2
    LEFT JOIN bar ON foo.id = bar.id
    LEFT JOIN baz ON foo.id = baz.id
);

@mhernand40
Copy link
Author

Great! I will give this a shot. Thank you very much.

@mhernand40
Copy link
Author

@AlecStrong thank you for the suggested workaround. I was able to apply something similar for my actual, more complex query. 🙂

@mecoFarid
Copy link

@AlecStrong Did this made to release? I am still getting this error:

SQLDelight version: 2.0.0-alpha05

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

Successfully merging a pull request may close this issue.

3 participants