Repodb: Bug: QueryAsync with empty QueryField list throws SQL exception

Created on 3 Aug 2020  路  5Comments  路  Source: mikependon/RepoDB

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 https://github.com/mikependon/RepoDb/issues/463

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

Fixed bug deployed request

All 5 comments

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.

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

No rush, the workaround is simple :)

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.

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

Was this page helpful?
0 / 5 - 0 ratings