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

Changed Contains query to ensure bool convertion #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

fsnader
Copy link

@fsnader fsnader commented Oct 7, 2019

Changed contains SQL query to ensure BIT casting and C# code to return always a bool

@@ -47,7 +47,8 @@ protected async Task<bool> ContainsAsync(IDictionary<string, object> filterValue
{
using (var command = connection.CreateContainsCommand(DatabaseDriver, Table.Schema, Table.Name, filterValues))
{
return (bool)await command.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false);
var queryResult = await command.ExecuteScalarAsync(cancellationToken).ConfigureAwait(false);
return queryResult is bool result && result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to throw an exception instead of silently accepting if the query returns a value different than boolean._

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe is better to remove this modification and leave just the changed SQL?

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