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

Not qualified columns when projection is null (relevant again) #86

Closed
frigus02 opened this issue Jun 5, 2015 · 3 comments
Closed

Not qualified columns when projection is null (relevant again) #86

frigus02 opened this issue Jun 5, 2015 · 3 comments

Comments

@frigus02
Copy link

frigus02 commented Jun 5, 2015

When the projection in a query is null, there are multiple columns with name "_id". See #40 for more detailed explanation.

The referenced issue was marked as solved, but I experience this problem now. I assume it was introduced again in the commit 5456651.

@yargray
Copy link
Contributor

yargray commented Sep 9, 2015

This problem was fixed absolutely in my pull request #88
Any feedback welcome

@BoD
Copy link
Owner

BoD commented Oct 23, 2016

I know this is more than a year late, and I'm sorry.
After thinking about this issue, here are my thoughts:

  • When using a null projection, the generated SQL is SELECT * FROM...
  • So if a join is used, there will definitely be several columns named _id in the resulting cursor
  • One possible way to address this could be to replace null by a list of all the columns of all the joined tables, and to alias the _id columns (for instance, company._id as company_id) - or to omit them (keep only the master table's _id column)
  • But this seems complicated to do and a bit non intuitive for the user (not really consistent with how null projections usually work in Android APIs)
  • Therefore my "fix" for now is to keep null, and only to put a comment in the README explaining to avoid using null projections with joined tables.

One last thought: null projections should be avoided in general, not just with joined tables. It is always more efficient to select specific columns.

@BoD BoD closed this as completed Oct 23, 2016
@yargray
Copy link
Contributor

yargray commented Dec 20, 2016

What about my pull request #88 ? It can solve the problem of null projection by default.

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

No branches or pull requests

3 participants