agent-sql 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +4 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -793,7 +793,10 @@ function checkJoinColumns(ast, schema) {
|
|
|
793
793
|
const joinSettings = schema[join.table.name];
|
|
794
794
|
if (joinSettings === void 0) return Err(new SanitiseError(`Table ${join.table.name} is not allowed`));
|
|
795
795
|
if (join.condition === null || join.condition.type === "join_using" || join.condition.expr.type !== "where_comparison" || join.condition.expr.operator !== "=" || join.condition.expr.left.type !== "where_value" || join.condition.expr.left.kind !== "column_ref" || join.condition.expr.right.type !== "where_value" || join.condition.expr.right.kind !== "column_ref") return Err(new SanitiseError("Only JOIN ON column_ref = column_ref supported"));
|
|
796
|
-
const
|
|
796
|
+
const leftRef = join.condition.expr.left.ref;
|
|
797
|
+
const rightRef = join.condition.expr.right.ref;
|
|
798
|
+
if (leftRef.table !== join.table.name && rightRef.table !== join.table.name) return Err(new SanitiseError(`JOIN ${join.table.name} ON clause does not reference ${join.table.name}`));
|
|
799
|
+
const { joining, foreign } = getJoinTableRef(join.table.name, leftRef, rightRef);
|
|
797
800
|
const joinTableCol = joinSettings[joining.name];
|
|
798
801
|
if (joinTableCol === void 0) return Err(new SanitiseError(`Tried to join using ${join.table.name}.${joining.name}`));
|
|
799
802
|
if (joinTableCol === null) {
|