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

NH-3028 - QueryOver with constants does only execute projections at the beginning of the select #1364

Open
nhibernate-bot opened this issue Oct 13, 2017 · 0 comments

Comments

@nhibernate-bot
Copy link
Collaborator

nhibernate-bot commented Oct 13, 2017

Daniel Marbach created an issue — 23rd January 2012, 16:16:46:

The following query works:

session.QueryOver(() => orderAlias)
                .Where(o => o.Id == this.orderId)
                .Select(
                    Projections.Constant(workpieceCount).WithAlias(() => orderDetailAlias.NumberOfWorkpieces),
                    Projections.Constant(toolCount).WithAlias(() => orderDetailAlias.NumberOfTools),
                    Projections.Property(() => orderAlias.Id).WithAlias(() => orderDetailAlias.Id),
                    Projections.Property(() => orderAlias.Name).WithAlias(() => orderDetailAlias.Name),
                    Projections.Property(() => orderAlias.Description).WithAlias(() => orderDetailAlias.Description),
                    Projections.Property(() => orderAlias.CreatedBy).WithAlias(() => orderDetailAlias.CreatedBy),
                    Projections.Property(() => orderAlias.CreationDate).WithAlias(() => orderDetailAlias.CreationDate),
                    Projections.Property(() => orderAlias.PlannedDeliveryDate).WithAlias(() => orderDetailAlias.PlannedDeliveryDate)
                    )
                .TransformUsing(Transformers.AliasToBean<OrderDetailData>())
                .SingleOrDefault<OrderDetailData>();

The following identical query does not work:

session.QueryOver(() => orderAlias)
                .Where(o => o.Id == this.orderId)
                .Select(
                    Projections.Property(() => orderAlias.Id).WithAlias(() => orderDetailAlias.Id),
                    Projections.Property(() => orderAlias.Name).WithAlias(() => orderDetailAlias.Name),
                    Projections.Property(() => orderAlias.Description).WithAlias(() => orderDetailAlias.Description),
                    Projections.Property(() => orderAlias.CreatedBy).WithAlias(() => orderDetailAlias.CreatedBy),
                    Projections.Property(() => orderAlias.CreationDate).WithAlias(() => orderDetailAlias.CreationDate),
                    Projections.Property(() => orderAlias.PlannedDeliveryDate).WithAlias(() => orderDetailAlias.PlannedDeliveryDate),
                    Projections.Constant(workpieceCount).WithAlias(() => orderDetailAlias.NumberOfWorkpieces),
                    Projections.Constant(toolCount).WithAlias(() => orderDetailAlias.NumberOfTools)
                    )
                .TransformUsing(Transformers.AliasToBean<OrderDetailData>())
                .SingleOrDefault<OrderDetailData>();

You can get it working if you randomly insert a constant projection before the other constants like:

session.QueryOver(() => orderAlias)
                .Where(o => o.Id == this.orderId)
                .Select(
                    Projections.Property(() => orderAlias.Id).WithAlias(() => orderDetailAlias.Id),
                    Projections.Property(() => orderAlias.Name).WithAlias(() => orderDetailAlias.Name),
                    Projections.Constant("Foooo").WithAlias(() => orderDetailAlias.Description),
                    Projections.Property(() => orderAlias.CreatedBy).WithAlias(() => orderDetailAlias.CreatedBy),
                    Projections.Property(() => orderAlias.CreationDate).WithAlias(() => orderDetailAlias.CreationDate),
                    Projections.Property(() => orderAlias.PlannedDeliveryDate).WithAlias(() => orderDetailAlias.PlannedDeliveryDate),
                    Projections.Constant(workpieceCount).WithAlias(() => orderDetailAlias.NumberOfWorkpieces),
                    Projections.Constant(toolCount).WithAlias(() => orderDetailAlias.NumberOfTools)
                    )
                .TransformUsing(Transformers.AliasToBean<OrderDetailData>())
                .SingleOrDefault<OrderDetailData>();

Daniel Marbach added a comment — 24th January 2012, 14:04:13:

Might help also:

https://github.com/danielmarbach/nhibernate-core-testcase/tree/sqlce-querying

and

https://nhibernate.jira.com/browse/NH-3033


Oskar Berggren added a comment — 12th November 2012, 21:16:19:

How does it fail? Could you create a minimal test case that illustrates the issue, as a pull request on github, please?


Daniel Marbach added a comment — 12th November 2012, 21:24:31:

I don’t know what you want more. Under:

https://github.com/danielmarbach/nhibernate-core-testcase/tree/sqlce-querying

is a full repro solution

Daniel

From: Oskar Berggren (JIRA) mailto:jira@nhibernate.jira.com
Sent: Montag, 12. November 2012 22:17
To: daniel.marbach@openplace.net
Subject: [JIRA] (NH-3028) QueryOver with constants does only execute projections at the beginning of the select

https://nhibernate.jira.com/s/en*USwq7kxo-418945332/812/55/*/jira-logo-scaled.png

https://nhibernate.jira.com/secure/useravatar?avatarId=10152 https://nhibernate.jira.com/secure/ViewProfile.jspa?name=oskar.berggren Oskar Berggren commented on Bug https://nhibernate.jira.com/images/icons/bug.gif https://nhibernate.jira.com/browse/NH-3028 NH-3028

https://nhibernate.jira.com/browse/NH-3028 QueryOver with constants does only execute projections at the beginning of the select

How does it fail? Could you create a minimal test case that illustrates the issue, as a pull request on github, please?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira http://www.atlassian.com/software/jira


Daniel Marbach added a comment — 12th November 2012, 21:24:50:

I don’t know what you want more. Under:

https://github.com/danielmarbach/nhibernate-core-testcase/tree/sqlce-querying

is a full repro solution

Daniel


Oskar Berggren added a comment — 12th November 2012, 21:40:38:

It is heavy on the "full" :)

I don't quite understand it... The idea is to inherit from BugTestCase so that you don't need all that setup code in the issue specific test fixture. And why the nuget? The NHibernate assembly and related stuff is already available in the lib folder. So is there something important about this, or just and oversight?

/Oskar


Daniel Marbach added a comment — 12th November 2012, 21:45:17:

Man, it's 10 months ago :D Used nuget to get other dependencies such as SqlCompact... And I wanted a repro solution which reflects the problem we saw.

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

No branches or pull requests

2 participants