Skip to content

Commit aa693ed

Browse files
Remove the auto conversion from: Where -> WhereExists
Remove the Select(params object[]) overload
1 parent 98cb5f9 commit aa693ed

File tree

3 files changed

+11
-45
lines changed

3 files changed

+11
-45
lines changed

QueryBuilder.Tests/QueryBuilderTest.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,22 @@ public void CombineRawWithPlaceholders()
340340
[Fact]
341341
public void NestedEmptyWhere()
342342
{
343+
// Empty nested where should be ignored
343344
var query = new Query("A").Where(q => new Query().Where(q2 => new Query().Where(q3 => new Query())));
344345

345346
var c = Compile(query);
346347

347348
Assert.Equal("SELECT * FROM [A]", c[0]);
348349
}
350+
351+
[Fact]
352+
public void NestedQuery()
353+
{
354+
var query = new Query("A").Where(q => new Query("B"));
355+
356+
var c = Compile(query);
357+
358+
Assert.Equal("SELECT * FROM [A]", c[0]);
359+
}
349360
}
350361
}

QueryBuilder/Base.Where.cs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -151,23 +151,6 @@ public Q Where(Func<Q, Q> callback)
151151
{
152152
var query = callback.Invoke(NewChild());
153153

154-
/*
155-
if (Has("from") && Get("from").FirstOrDefault() is From)
156-
{
157-
query.From((Get("from").FirstOrDefault() as From).Table);
158-
}
159-
*/
160-
161-
if (query.HasComponent("from"))
162-
{
163-
return AddComponent("where", new ExistsCondition<Q>
164-
{
165-
Query = query,
166-
IsNot = getNot(),
167-
IsOr = getOr(),
168-
});
169-
}
170-
171154
return AddComponent("where", new NestedCondition<Q>
172155
{
173156
Query = query,

QueryBuilder/Query.Select.cs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,34 +37,6 @@ public Query SelectRaw(string expression, params object[] bindings)
3737
return this;
3838
}
3939

40-
41-
public Query Select(params object[] columns)
42-
{
43-
foreach (var item in columns)
44-
{
45-
if (item is Raw)
46-
{
47-
SelectRaw((item as Raw).Value, (item as Raw).Bindings);
48-
}
49-
else if (item is string)
50-
{
51-
Select((string)item);
52-
}
53-
else if (item is Query)
54-
{
55-
var query = item as Query;
56-
57-
Select(query, query.QueryAlias);
58-
}
59-
else
60-
{
61-
throw new ArgumentException("only `String`, `Raw` and `Query` are allowed");
62-
}
63-
}
64-
65-
return this;
66-
}
67-
6840
public Query Select(Query query, string alias)
6941
{
7042
Method = "select";

0 commit comments

Comments
 (0)