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

Boolean in select #4141

Merged
merged 1 commit into from
Jan 8, 2016
Merged

Boolean in select #4141

merged 1 commit into from
Jan 8, 2016

Conversation

smitpatel
Copy link
Contributor

resolves #3703
Issue: SQL does not allow not operation on Boolean type directly. They must be compared with true or false. Fix is to convert unary operations on Boolean type to comparison operation.
resolves #3618
Issue: SQL does not allow comparison operation into projection. They must be wrapped in Case When Then block.
Fix: Whenever there is comparison operation into projection, convert it to conditional expression.
If comparison operation is inside conditional expression already then do no convert.
Issue: Comparison follows null semantics.
Implementation: While processing SelectExpression process the projection accordingly.
resolves #649 for projections

@smitpatel smitpatel force-pushed the booleanInSelect branch 3 times, most recently from 4848708 to 2d7604e Compare December 21, 2015 18:33
@anpete anpete self-assigned this Jan 6, 2016
@@ -143,7 +143,14 @@ public virtual Expression VisitSelect(SelectExpression selectExpression)
_relationalCommandBuilder.Append(", ");
}

VisitJoin(selectExpression.Projection);
var comparisonTransformer = new ProjectionComparisonTransformingVisitor();
var nullComparisonTransformer = new NullComparisonTransformingVisitor(_parametersValues);
Copy link
Contributor

Choose a reason for hiding this comment

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

DRY this up with predicate case below.

@smitpatel smitpatel force-pushed the booleanInSelect branch 3 times, most recently from 5234fd1 to c1fa3a3 Compare January 8, 2016 02:13
@smitpatel
Copy link
Contributor Author

Updated
Split converting comparison to case block to SqlServer Specific. Null semantics are required for SQLite too so it is in relational.

@anpete
Copy link
Contributor

anpete commented Jan 8, 2016

@smitpatel Does this potentially resolve #649?

@@ -1125,7 +1132,7 @@ protected virtual bool TryGenerateBinaryOperator(ExpressionType op, [NotNull] ou
protected override Exception CreateUnhandledItemException<T>(T unhandledItem, string visitMethod)
=> new NotImplementedException(visitMethod);

private class NullComparisonTransformingVisitor : RelinqExpressionVisitor
protected class NullComparisonTransformingVisitor : RelinqExpressionVisitor
Copy link
Contributor

Choose a reason for hiding this comment

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

This need to be protected?

@smitpatel
Copy link
Contributor Author

#649 is resolved by this at least for projections. Added test for it.

@anpete
Copy link
Contributor

anpete commented Jan 8, 2016

:shipit:

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.

3 participants