Querydsl SQL: Remove duplicate columns from projection #314

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

Comments

Projects
None yet
2 participants
@ssaarela
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Dec 13, 2012

Member

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?

Member

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

This comment has been minimized.

Show comment
Hide comment
@ssaarela

ssaarela Dec 13, 2012

Contributor

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

Contributor

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

#314 move duplicate removal to MappingProjection, since QTuple is us…
…ed internally in nearly all query implementations
@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Dec 14, 2012

Member

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

Member

timowest commented Dec 14, 2012

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

@timowest

This comment has been minimized.

Show comment
Hide comment
@timowest

timowest Jan 13, 2013

Member

Released in 3.0.0.BETA1

Member

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