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

Bug: QueryAsync with empty QueryField list throws SQL exception #498

Closed
asleire opened this issue Aug 3, 2020 · 5 comments
Closed

Bug: QueryAsync with empty QueryField list throws SQL exception #498

asleire opened this issue Aug 3, 2020 · 5 comments
Assignees
Labels
bug Something isn't working deployed Feature or bug is deployed at the current release fixed The bug, issue, incident has been fixed. request A request from the community.

Comments

@asleire
Copy link

asleire commented Aug 3, 2020

Currently using RepoDb.SqlServer 1.0.13

The code db.QueryAsync<SettingTagDbo>(Enumerable.Empty<QueryField>()) generates the following invalid SQL
SELECT [SettingDefinitionSet], [SettingCollection], [SettingCollectionValue], [ResourceType], [ResourceId], [Path], [SettingType], [TagType], [Value] FROM [SettingTag] WHERE () ;

I would expect QueryAsync with an empty QueryField list to be equivalent to QueryAllAsync

This appears to be a similar yet different error than in #463

Current workaround is similar, call QueryAllAsync or QueryAsync depending on whether QueryField list is empty

@mikependon mikependon self-assigned this Aug 3, 2020
@mikependon mikependon added the request A request from the community. label Aug 3, 2020
@mikependon
Copy link
Owner

Thanks for this and it is acknowledge. I will do fix this. It is actually working if you're to use the 'whereOrPrimaryKey' passing the nulls.

var data = await connection.QueryAsync<SettingTagDbo>(whereOrPrimaryKey: null);

You are correct, it should behave like QueryAllAsync.

@mikependon
Copy link
Owner

I hope you are not block by this for now. Thanks

@mikependon mikependon added the bug Something isn't working label Aug 3, 2020
@mikependon mikependon changed the title QueryAsync with empty QueryField list throws SQL exception Bug: QueryAsync with empty QueryField list throws SQL exception Aug 3, 2020
@asleire
Copy link
Author

asleire commented Aug 3, 2020

No rush, the workaround is simple :)

@mikependon
Copy link
Owner

mikependon commented Aug 3, 2020

The fix is simple as well, see here. Instead of 'null-checks', we can do the 'presence-check' like queryGroups?.Any() == true somewhere.

EDIT: The fix seems to be checking of the QueryField object inside that QueryGroup object.

mikependon added a commit that referenced this issue Aug 3, 2020
mikependon added a commit that referenced this issue Aug 3, 2020
@mikependon mikependon added the fixed The bug, issue, incident has been fixed. label Aug 3, 2020
@mikependon mikependon added the deployed Feature or bug is deployed at the current release label Aug 29, 2020
@mikependon
Copy link
Owner

Closing this ticket now. Kindly let us know if you have any questions. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working deployed Feature or bug is deployed at the current release fixed The bug, issue, incident has been fixed. request A request from the community.
Projects
None yet
Development

No branches or pull requests

2 participants