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

Querydsl SQL: Remove duplicate columns from projection #314

Closed
ssaarela opened this issue Dec 13, 2012 · 4 comments
Closed

Querydsl SQL: Remove duplicate columns from projection #314

ssaarela opened this issue Dec 13, 2012 · 4 comments
Milestone

Comments

@ssaarela
Copy link
Contributor

@ssaarela ssaarela commented Dec 13, 2012

Especially when dealing with multiple column keys, same table may have keys that share columns. For example parent-child relation for table xxx with (a,b) primary key:

create table ex (
a integer,
b integer,
c integer,
foreign key (a, b) references xxx (a,b),
foreign key (a, c) references xxx (a,b)
);

Having MappingProjection with nested multi-column mappings for these keys results in an error because select contains a of table ex twice:

qry.list(MappingProjection(childKeyMapping, parentKeyMapping)

where

child/parentKeyMappings are also MappingProjections. One with (a,b) and the other with (a, c).

I guess you could make an alias for the second mapping (a.as(a2), b) but having Qdsl remove duplicate columns automatically would be so much easier and more intuitive for the user.

@timowest
Copy link
Member

@timowest timowest commented Dec 13, 2012

I guess you could alias for the second mapping (a.as(a2), b) but having Qdsl remove duplicate columns automatically would be so much easier and more intuitive for the user.

I'd hesitate to remove duplicate projection expressions on the query level, but maybe they could be removed for certain projections such as QTuple and MappingProjection.

Is that ok with you?

@ssaarela
Copy link
Contributor Author

@ssaarela ssaarela commented Dec 13, 2012

My "challenges" have been with MappingProjection, so that would most definitely help :)

timowest added a commit that referenced this issue Dec 14, 2012
timowest added a commit that referenced this issue Dec 14, 2012
…d internally in nearly all query implementations
@timowest
Copy link
Member

@timowest timowest commented Dec 14, 2012

The duplicate removal is now in MappingProjection, since QTuple is used also internally in many query implementations.

@timowest
Copy link
Member

@timowest timowest commented Jan 13, 2013

Released in 3.0.0.BETA1

@timowest timowest closed this Jan 13, 2013
@timowest timowest added this to the 3.0.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants