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

fix invalid condition used in QueryFirst and QuerySingle #554

Closed

Conversation

neuecc
Copy link

@neuecc neuecc commented Jul 11, 2016

I think (row & Row.Single) != 0 is row is not Row.First so should swap condition.

By the way, in MySQL if use CommandBehavior.SingleRow, MySQL Connector execute SET SQL_SELECT_LIMIT=1 on each query. (at command.cs - HandleCommandBeehaviors)
It causes performance issue so I need disable command behavior option...

@mgravell
Copy link
Member

mgravell commented Sep 8, 2016

I think the code is correct as written.

(row & Row.Single) != 0 is true for Single and SingleOrDefault. In those cases we have to read multiple rows in order to validate that we have actually only got one, hence not passing SingleRow.

Conversely, (row & Row.Single) != 0 is false for First and FirstOrDefault. In that scenario we can use the "single row" optimization, precisely because we don't care whether multiple rows would have otherwise been returned.

@mgravell
Copy link
Member

mgravell commented Sep 8, 2016

Re the performance thing; we're discussing options as to whether we should disable those flags.

mgravell added a commit that referenced this pull request Sep 8, 2016
…SingleResult=disallowed - but expose options; this fixes issues like #563 automatically, and allows the performance aspect  of #554 to be fixed via a global setting
@mgravell
Copy link
Member

mgravell commented Sep 8, 2016

Closing; I think the code change is invalid (please let me know if I've misunderstood - it happens); the performance thing should be addressed by #602

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 this pull request may close these issues.

2 participants