@leonardovida-md/drizzle-neo-duckdb 1.1.2 → 1.1.4

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/src/session.ts CHANGED
@@ -15,7 +15,10 @@ import type {
15
15
  } from 'drizzle-orm/relations';
16
16
  import { fillPlaceholders, type Query, SQL, sql } from 'drizzle-orm/sql/sql';
17
17
  import type { Assume } from 'drizzle-orm/utils';
18
- import { adaptArrayOperators } from './sql/query-rewriters.ts';
18
+ import {
19
+ adaptArrayOperators,
20
+ qualifyJoinColumns,
21
+ } from './sql/query-rewriters.ts';
19
22
  import { mapResultRow } from './sql/result-mapper.ts';
20
23
  import { TransactionRollbackError } from 'drizzle-orm/errors';
21
24
  import type { DuckDBDialect } from './dialect.ts';
@@ -61,8 +64,24 @@ function rewriteQuery(
61
64
  return { sql: query, rewritten: false };
62
65
  }
63
66
 
64
- const rewritten = adaptArrayOperators(query);
65
- return { sql: rewritten, rewritten: rewritten !== query };
67
+ let result = query;
68
+ let wasRewritten = false;
69
+
70
+ // Rewrite Postgres array operators to DuckDB functions
71
+ const arrayRewritten = adaptArrayOperators(result);
72
+ if (arrayRewritten !== result) {
73
+ result = arrayRewritten;
74
+ wasRewritten = true;
75
+ }
76
+
77
+ // Qualify unqualified column references in JOIN ON clauses
78
+ const joinQualified = qualifyJoinColumns(result);
79
+ if (joinQualified !== result) {
80
+ result = joinQualified;
81
+ wasRewritten = true;
82
+ }
83
+
84
+ return { sql: result, rewritten: wasRewritten };
66
85
  }
67
86
 
68
87
  export class DuckDBPreparedQuery<