|
@@ -222,4 +222,42 @@ describe("Parser", () => {
|
222
|
222
|
}),
|
223
|
223
|
]);
|
224
|
224
|
});
|
|
225
|
+
|
|
226
|
+ it("should parse chained ANDs", () => {
|
|
227
|
+ const tree = parse("select a from b where c and d and e");
|
|
228
|
+ expect(tree).to.deep.equal([
|
|
229
|
+ new AST.SelectStatement({
|
|
230
|
+ arguments: [new AST.Identifier("a")],
|
|
231
|
+ from: new AST.Identifier("b"),
|
|
232
|
+ where: new AST.Binary({
|
|
233
|
+ left: new AST.Binary({
|
|
234
|
+ left: new AST.Identifier("c"),
|
|
235
|
+ right: new AST.Identifier("d"),
|
|
236
|
+ type: AST.BinaryExpressionTypes.AND,
|
|
237
|
+ }),
|
|
238
|
+ right: new AST.Identifier("e"),
|
|
239
|
+ type: AST.BinaryExpressionTypes.AND,
|
|
240
|
+ }),
|
|
241
|
+ }),
|
|
242
|
+ ]);
|
|
243
|
+ });
|
|
244
|
+
|
|
245
|
+ it("should parse chained ORs", () => {
|
|
246
|
+ const tree = parse("select a from b where c or d or e");
|
|
247
|
+ expect(tree).to.deep.equal([
|
|
248
|
+ new AST.SelectStatement({
|
|
249
|
+ arguments: [new AST.Identifier("a")],
|
|
250
|
+ from: new AST.Identifier("b"),
|
|
251
|
+ where: new AST.Binary({
|
|
252
|
+ left: new AST.Binary({
|
|
253
|
+ left: new AST.Identifier("c"),
|
|
254
|
+ right: new AST.Identifier("d"),
|
|
255
|
+ type: AST.BinaryExpressionTypes.OR,
|
|
256
|
+ }),
|
|
257
|
+ right: new AST.Identifier("e"),
|
|
258
|
+ type: AST.BinaryExpressionTypes.OR,
|
|
259
|
+ }),
|
|
260
|
+ }),
|
|
261
|
+ ]);
|
|
262
|
+ });
|
225
|
263
|
});
|