Skip to content

Commit

Permalink
Remove the auto conversion from: Where -> WhereExists
Browse files Browse the repository at this point in the history
Remove the Select(params object[]) overload
  • Loading branch information
ahmad-moussawi committed Mar 4, 2018
1 parent 98cb5f9 commit aa693ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 45 deletions.
11 changes: 11 additions & 0 deletions QueryBuilder.Tests/QueryBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,22 @@ public void CombineRawWithPlaceholders()
[Fact]
public void NestedEmptyWhere()
{
// Empty nested where should be ignored
var query = new Query("A").Where(q => new Query().Where(q2 => new Query().Where(q3 => new Query())));

var c = Compile(query);

Assert.Equal("SELECT * FROM [A]", c[0]);
}

[Fact]
public void NestedQuery()
{
var query = new Query("A").Where(q => new Query("B"));

var c = Compile(query);

Assert.Equal("SELECT * FROM [A]", c[0]);
}
}
}
17 changes: 0 additions & 17 deletions QueryBuilder/Base.Where.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,6 @@ public Q Where(Func<Q, Q> callback)
{
var query = callback.Invoke(NewChild());

/*
if (Has("from") && Get("from").FirstOrDefault() is From)
{
query.From((Get("from").FirstOrDefault() as From).Table);
}
*/

if (query.HasComponent("from"))
{
return AddComponent("where", new ExistsCondition<Q>
{
Query = query,
IsNot = getNot(),
IsOr = getOr(),
});
}

return AddComponent("where", new NestedCondition<Q>
{
Query = query,
Expand Down
28 changes: 0 additions & 28 deletions QueryBuilder/Query.Select.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,34 +37,6 @@ public Query SelectRaw(string expression, params object[] bindings)
return this;
}


public Query Select(params object[] columns)
{
foreach (var item in columns)
{
if (item is Raw)
{
SelectRaw((item as Raw).Value, (item as Raw).Bindings);
}
else if (item is string)
{
Select((string)item);
}
else if (item is Query)
{
var query = item as Query;

Select(query, query.QueryAlias);
}
else
{
throw new ArgumentException("only `String`, `Raw` and `Query` are allowed");
}
}

return this;
}

public Query Select(Query query, string alias)
{
Method = "select";
Expand Down

0 comments on commit aa693ed

Please sign in to comment.