You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit df4a237
Browse filesBrowse the repository at this point in the historyBrowse files
Assert.Equal("SELECT [ProductId], [QuantityPerUnit] FROM [Products] WHERE LOWER([QuantityPerUnit]) like '%500%'",c1[EngineCodes.SqlServer]);
116
-
Assert.Equal("SELECT [ProductId], [QuantityPerUnit] FROM [Products] WHERE [QuantityPerUnit] like '%500%'",c2[EngineCodes.SqlServer]);
117
82
83
+
Assert.Equal("SELECT [ProductId], [QuantityPerUnit] FROM [Products] WHERE [QuantityPerUnit] like '%500%'",c1[EngineCodes.SqlServer]);
118
84
}
119
85
120
-
121
86
[Fact]
122
87
publicvoidTest_Define_WhereLike()
123
88
{
@@ -126,18 +91,9 @@ public void Test_Define_WhereLike()
126
91
.Define("@id","20")
127
92
.WhereLike("SupplierID",Variable("@id"));
128
93
129
-
130
-
varquery2=newQuery("Products")
131
-
.Select("ProductId","ProductName","SupplierID")
132
-
.Define("@id","20")
133
-
.WhereLike("SupplierID",Variable("@id"),true);
134
-
135
94
varc1=Compile(query1);
136
-
varc2=Compile(query2);
137
-
138
-
Assert.Equal("SELECT [ProductId], [ProductName], [SupplierID] FROM [Products] WHERE LOWER([SupplierID]) like '20'",c1[EngineCodes.SqlServer]);
139
95
140
-
Assert.Equal("SELECT [ProductId], [ProductName], [SupplierID] FROM [Products] WHERE [SupplierID] like '20'",c2[EngineCodes.SqlServer]);
96
+
Assert.Equal("SELECT [ProductId], [ProductName], [SupplierID] FROM [Products] WHERE [SupplierID] like '20'",c1[EngineCodes.SqlServer]);
141
97
}
142
98
143
99
@@ -202,7 +158,7 @@ public void Test_Define_HavingStarts()
202
158
203
159
varc=Compile(query);
204
160
205
-
Assert.Equal("SELECT COUNT(CustomerID), [Country] FROM [Customers] GROUP BY [Country] HAVING LOWER([Country]) like 'u%'",c[EngineCodes.SqlServer]);
161
+
Assert.Equal("SELECT COUNT(CustomerID), [Country] FROM [Customers] GROUP BY [Country] HAVING [Country] like 'U%'",c[EngineCodes.SqlServer]);
206
162
207
163
}
208
164
@@ -220,7 +176,7 @@ public void Test_Define_Having_Ends()
220
176
221
177
varc=Compile(query);
222
178
223
-
Assert.Equal("SELECT COUNT(CustomerID), [Country] FROM [Customers] GROUP BY [Country] HAVING LOWER([Country]) like '%d'",c[EngineCodes.SqlServer]);
179
+
Assert.Equal("SELECT COUNT(CustomerID), [Country] FROM [Customers] GROUP BY [Country] HAVING [Country] like '%d'",c[EngineCodes.SqlServer]);
224
180
}
225
181
226
182
@@ -238,7 +194,7 @@ public void Test_Define_Having_Contains()
238
194
239
195
varc=Compile(query);
240
196
241
-
Assert.Equal("SELECT COUNT(CustomerID), [Country] FROM [Customers] GROUP BY [Country] HAVING LOWER([Country]) like '%d%'",c[EngineCodes.SqlServer]);
197
+
Assert.Equal("SELECT COUNT(CustomerID), [Country] FROM [Customers] GROUP BY [Country] HAVING [Country] like '%d%'",c[EngineCodes.SqlServer]);
242
198
243
199
}
244
200
@@ -367,7 +323,7 @@ public void Test_Define_Union()
367
323
.WhereNotLike("City",Variable("@city"));
368
324
369
325
varc=Compile(q2);
370
-
Assert.Equal("SELECT [City] FROM [Customers] WHERE NOT (LOWER([City]) like 'z') UNION SELECT [City] FROM [Suppliers] WHERE [City] = 'Beirut'",c[EngineCodes.SqlServer]);
326
+
Assert.Equal("SELECT [City] FROM [Customers] WHERE NOT ([City] like 'Z') UNION SELECT [City] FROM [Suppliers] WHERE [City] = 'Beirut'",c[EngineCodes.SqlServer]);
371
327
}
372
328
373
329
@@ -386,7 +342,7 @@ public void Test_Define_Except()
386
342
.WhereNotLike("City",Variable("@city"));
387
343
388
344
varc=Compile(q2);
389
-
Assert.Equal("SELECT [City] FROM [Customers] WHERE NOT (LOWER([City]) like 'z') EXCEPT SELECT [City] FROM [Suppliers] WHERE [City] = 'Beirut'",c[EngineCodes.SqlServer]);
345
+
Assert.Equal("SELECT [City] FROM [Customers] WHERE NOT ([City] like 'Z') EXCEPT SELECT [City] FROM [Suppliers] WHERE [City] = 'Beirut'",c[EngineCodes.SqlServer]);
390
346
}
391
347
392
348
[Fact]
@@ -404,7 +360,7 @@ public void Test_Define_Intersect()
404
360
.WhereNotLike("City",Variable("@city"));
405
361
406
362
varc=Compile(q2);
407
-
Assert.Equal("SELECT [City] FROM [Customers] WHERE NOT (LOWER([City]) like 'z') INTERSECT SELECT [City] FROM [Suppliers] WHERE [City] = 'Beirut'",c[EngineCodes.SqlServer]);
363
+
Assert.Equal("SELECT [City] FROM [Customers] WHERE NOT ([City] like 'Z') INTERSECT SELECT [City] FROM [Suppliers] WHERE [City] = 'Beirut'",c[EngineCodes.SqlServer]);
Copy file name to clipboardExpand all lines: QueryBuilder.Tests/DeleteTests.cs
+18-5Lines changed: 18 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -27,10 +27,13 @@ public void DeleteWithJoin()
27
27
.Where("Authors.Id",5)
28
28
.AsDelete();
29
29
30
-
varc=Compile(q);
30
+
Assert.Equal("DELETE [Posts] FROM [Posts] \nINNER JOIN [Authors] ON [Authors].[Id] = [Posts].[AuthorId] WHERE [Authors].[Id] = 5",Compilers.CompileFor(EngineCodes.SqlServer,q).ToString());
31
+
Assert.Equal("DELETE `Posts` FROM `Posts` \nINNER JOIN `Authors` ON `Authors`.`Id` = `Posts`.`AuthorId` WHERE `Authors`.`Id` = 5",Compilers.CompileFor(EngineCodes.MySql,q).ToString());
31
32
32
-
Assert.Equal("DELETE [Posts] FROM [Posts] \nINNER JOIN [Authors] ON [Authors].[Id] = [Posts].[AuthorId] WHERE [Authors].[Id] = 5",c[EngineCodes.SqlServer]);
33
-
Assert.Equal("DELETE `Posts` FROM `Posts` \nINNER JOIN `Authors` ON `Authors`.`Id` = `Posts`.`AuthorId` WHERE `Authors`.`Id` = 5",c[EngineCodes.MySql]);
@@ -41,9 +44,19 @@ public void DeleteWithJoinAndAlias()
41
44
.Where("Authors.Id",5)
42
45
.AsDelete();
43
46
44
-
varc=Compile(q);
47
+
Assert.Equal("DELETE [P] FROM [Posts] AS [P] \nINNER JOIN [Authors] ON [Authors].[Id] = [P].[AuthorId] WHERE [Authors].[Id] = 5",Compilers.CompileFor(EngineCodes.SqlServer,q).ToString());
48
+
Assert.Equal("DELETE `P` FROM `Posts` AS `P` \nINNER JOIN `Authors` ON `Authors`.`Id` = `P`.`AuthorId` WHERE `Authors`.`Id` = 5",Compilers.CompileFor(EngineCodes.MySql,q).ToString());
49
+
}
50
+
51
+
[Fact]
52
+
publicvoidDeleteWithJoinAndSchema()
53
+
{
54
+
varq=newQuery("Audit.Posts")
55
+
.Join("Authors","Authors.Id","Posts.AuthorId")
56
+
.AsDelete();
45
57
46
-
Assert.Equal("DELETE [P] FROM [Posts] AS [P] \nINNER JOIN [Authors] ON [Authors].[Id] = [P].[AuthorId] WHERE [Authors].[Id] = 5",c[EngineCodes.SqlServer]);
58
+
Assert.Equal("DELETE [Posts] FROM [Audit].[Posts] \nINNER JOIN [Authors] ON [Authors].[Id] = [Posts].[AuthorId]",Compilers.CompileFor(EngineCodes.SqlServer,q).ToString());
59
+
Assert.Equal("DELETE `Posts` FROM `Audit`.`Posts` \nINNER JOIN `Authors` ON `Authors`.`Id` = `Posts`.`AuthorId`",Compilers.CompileFor(EngineCodes.MySql,q).ToString());
0 commit comments