Skip to content

GH-1879 - Allow Coalesce and Conditional logic on entity properties #1880

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

Merged
merged 6 commits into from
Oct 25, 2018

Conversation

PleasantD
Copy link
Contributor

See issue #1879 for details

{
private readonly QueryModel _originalSubQueryModel;
private int _depth = -1;
private readonly IList<bool> _nominate = new List<bool>();
Copy link
Member

Choose a reason for hiding this comment

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

Shoudn't this be a Stack<bool>?

newTrue = BuildNewSubQuery(newTrue);
Rewritten = true;
}
_nominate.Insert(_depth, false);
Copy link
Member

Choose a reason for hiding this comment

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

Isn't a RemoveAt(_depth) lacking here? (So a Pop, if converted to a stack.)

using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
Copy link
Member

Choose a reason for hiding this comment

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

From all the System usings, only using System.Linq.Expressions; is actually needed.

where T : Expression
where TVisitor : ConditionalQueryReferenceExpressionRewriter<T, TVisitor>, new()
{
protected System.Type QueryType { get; private set; }
Copy link
Member

Choose a reason for hiding this comment

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

It has no usage in current subclasses. Shouldn't it be turned into a private field?

return Expression.Condition(
Expression.NotEqual(node.Left, Expression.Constant(null, node.Left.Type)),
this.Visit(node.Left),
this.Visit(node.Right));
Copy link
Member

@fredericDelaporte fredericDelaporte Oct 20, 2018

Choose a reason for hiding this comment

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

Using this, when no conflict mandates it, is not the usual practice of NHibernate code base. this qualifiers should not be used wherever possible in new or modified code.

using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
Copy link
Member

Choose a reason for hiding this comment

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

From all the System usings, only System.Collections.Generic and System.Linq.Expressions are actually needed.

@@ -27,6 +27,9 @@ public class QueryModelVisitor : NhQueryModelVisitorBase, INhQueryModelVisitor
public static ExpressionToHqlTranslationResults GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, bool root,
NhLinqExpressionReturnType? rootReturnType)
{
// Expand conditionals in subquery FROM clauses into multiple subqueries
SubQueryConditionalExpander.ReWrite(queryModel);

Copy link
Member

Choose a reason for hiding this comment

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

Some undue trailing whitespaces are left on line 32. @hazzik, shouldn't we add in .editorconfig trim_trailing_whitespace = true? Of course it may at first generate some noise on edited files by removing all trailing whitespaces.

@PleasantD

This comment has been minimized.

@PleasantD
Copy link
Contributor Author

I added additional tests for Method and Extension Method access.
I had to fix WhereJoinDetector and MemberExpressionJoinDetector to correctly treat method calls as "member access" when considering expressions for joins.

I think I got all the other clean up as well.

…tity properties and collections (LINQ)

Add missing async generation
…tity properties and collections (LINQ)

Do additional minor cleanup
@fredericDelaporte

This comment has been minimized.

fredericDelaporte and others added 2 commits October 23, 2018 08:39
…tity properties and collections (LINQ)

Use a stack instead of a list with a pointer to "depth"
@fredericDelaporte fredericDelaporte added this to the 5.2 milestone Oct 23, 2018
@PleasantD
Copy link
Contributor Author

I added some additional checks and logic to handle nested conditionals in subqueries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants