Permalink
Browse files

Fixing wrong table for IsIn with index

  • Loading branch information...
sebastienros committed Dec 22, 2017
1 parent 432b678 commit 76ca0d1d3655eb4f4b54fbf0fd65138fe9e47472
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/YesSql.Core/Services/DefaultQuery.cs
@@ -136,6 +136,9 @@ static DefaultQuery()
var selector = expression.Arguments[1];
var predicate = expression.Arguments[2];
var tIndex = ((LambdaExpression)((UnaryExpression)selector).Operand).Parameters[0].Type;
query._bound.Add(tIndex);
var sqlBuilder = query._dialect.CreateBuilder(query._session._store.Configuration.TablePrefix);
// Build inner query
@@ -151,6 +154,8 @@ static DefaultQuery()
query.ConvertPredicate(_builder, ((LambdaExpression)((UnaryExpression)predicate).Operand).Body);
sqlBuilder.WhereAlso(_builder.ToString());
query._bound.RemoveAt(query._bound.Count - 1);
// Insert query
query.ConvertFragment(builder, expression.Arguments[0]);
builder.Append(dialect.InSelectOperator(sqlBuilder.ToSqlString(dialect)));
@@ -162,6 +167,9 @@ static DefaultQuery()
var selector = expression.Arguments[1];
var predicate = expression.Arguments[2];
var tIndex = ((LambdaExpression)((UnaryExpression)selector).Operand).Parameters[0].Type;
query._bound.Add(tIndex);
var sqlBuilder = query._dialect.CreateBuilder(query._session._store.Configuration.TablePrefix);
// Build inner query
@@ -173,10 +181,12 @@ static DefaultQuery()
sqlBuilder.Selector(_builder.ToString());
_builder.Clear();
sqlBuilder.Table(((LambdaExpression)((UnaryExpression)selector).Operand).Parameters[0].Type.Name);
sqlBuilder.Table(query._bound.Last().Name);
query.ConvertPredicate(_builder, ((LambdaExpression)((UnaryExpression)predicate).Operand).Body);
sqlBuilder.WhereAlso(_builder.ToString());
query._bound.RemoveAt(query._bound.Count - 1);
// Insert query
query.ConvertFragment(builder, expression.Arguments[0]);
builder.Append(dialect.NotInSelectOperator(sqlBuilder.ToSqlString(dialect)));

0 comments on commit 76ca0d1

Please sign in to comment.