Fix for IS NOT NULL
This commit is contained in:
@@ -1233,7 +1233,7 @@ export class TSQLParseTreeConverter implements TSQLParserVisitor<any> {
|
||||
return {
|
||||
expression_type: "compare_operation",
|
||||
left: this.visitAsExpr(ctx.columnExpr()),
|
||||
right: { value: null } as Constant,
|
||||
right: { expression_type: "constant", value: null } as Constant,
|
||||
op: ctx.NOT() ? CompareOperationOp.NotEq : CompareOperationOp.Eq,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -320,11 +320,23 @@ describe("ClickHousePrinter", () => {
|
||||
expect(sql).toContain("isNull(");
|
||||
});
|
||||
|
||||
it("should handle IS NOT NULL comparisons", () => {
|
||||
it("should handle != NULL comparisons", () => {
|
||||
const { sql } = printQuery("SELECT * FROM task_runs WHERE started_at != NULL");
|
||||
|
||||
expect(sql).toContain("isNotNull(");
|
||||
});
|
||||
|
||||
it("should handle IS NULL syntax", () => {
|
||||
const { sql } = printQuery("SELECT * FROM task_runs WHERE error IS NULL");
|
||||
|
||||
expect(sql).toContain("isNull(error)");
|
||||
});
|
||||
|
||||
it("should handle IS NOT NULL syntax", () => {
|
||||
const { sql } = printQuery("SELECT * FROM task_runs WHERE error IS NOT NULL");
|
||||
|
||||
expect(sql).toContain("isNotNull(error)");
|
||||
});
|
||||
});
|
||||
|
||||
describe("ORDER BY clauses", () => {
|
||||
|
||||
@@ -238,7 +238,9 @@ export class ClickHousePrinter {
|
||||
response = this.visitSampleExpr(node as SampleExpr);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedError(`Unknown expression type: ${nodeType}`);
|
||||
throw new NotImplementedError(
|
||||
`Unknown expression type: ${nodeType}. Node: ${JSON.stringify(node, null, 2).slice(0, 200)}`
|
||||
);
|
||||
}
|
||||
|
||||
this.indentLevel--;
|
||||
|
||||
Reference in New Issue
Block a user