Skip to content

feat: emit Oracle-compatible builder SQL - #109

Merged
ryanrasti merged 1 commit into
mainfrom
oracle-builder-sql
Aug 16, 2026
Merged

feat: emit Oracle-compatible builder SQL#109
ryanrasti merged 1 commit into
mainfrom
oracle-builder-sql

Conversation

@ryanrasti

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the SQL builder/compiler to emit Oracle-compatible SQL, primarily by adjusting alias syntax, pagination clauses, and mutation support gaps (RETURNING / DEFAULT handling) so Oracle can compile/execute the same builder constructs as Postgres/SQLite.

Changes:

  • Remove AS for table/VALUES source aliases (Oracle rejects AS for table aliases) and adjust VALUES alias commentary accordingly.
  • Emit Oracle pagination syntax (OFFSET … ROWS + FETCH FIRST/NEXT … ROWS ONLY) and remove top-level query parentheses during compilation to avoid Oracle parser inconsistencies.
  • Extend insert behavior to support Oracle’s DEFAULT keyword for per-row values, add Oracle-specific “all-default insert” spelling, and explicitly reject .returning() for Oracle mutations until OUT binds are implemented.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/builder/values.ts Updates VALUES alias documentation and minor formatting.
src/builder/update.ts Omits AS for Oracle UPDATE aliases; rejects RETURNING for Oracle updates.
src/builder/sql.ts Adds query-parenthesis metadata and unwraps top-level query parentheses in compile().
src/builder/query.ts Marks queries as parenthesized nodes; omits AS for table aliases; adds Oracle pagination emission.
src/builder/oracle.test.ts Adds compile-time SQL shape tests for Oracle dialect output.
src/builder/oracle-live.test.ts Adds optional live execution tests for Oracle (guarded by ORACLE_URL).
src/builder/insert.ts Adds Oracle DEFAULT support, all-default insert spelling, Oracle alias clause handling, and rejects RETURNING.
src/builder/delete.ts Omits AS for Oracle DELETE aliases; rejects RETURNING for Oracle deletes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/builder/sql.ts Outdated
Comment on lines +416 to +423
const text = out.join("");
return {
// Top-level parenthesized SELECTs are not consistently accepted by
// Oracle. Nested query nodes retain the wrapper because root then
// refers to their containing SQL node.
text: root.isParenthesizedQuery ? text.slice(1, -1) : text,
values,
};

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.

Suppressed comments (3)

src/builder/values.ts:35

  • This comment also refers to a specific alias name (q(...)). The emitted alias is determined by QueryBuilder’s registered alias (based on tsAlias, with potential suffixing), so the comment should describe the generic form.
  // Return the pre-alias VALUES fragment. QB appends `q(col1, col2, ...)`.

src/builder/values.ts:9

  • The comment mentions a hard-coded alias name (q(...)), but Values uses whatever table alias QueryBuilder registers (typically derived from tsAlias, and can be suffixed on conflict). This is misleading when reading the code and when debugging compiled SQL.

This issue also appears on line 35 of the same file.

  // VALUES emits `q(col1, col2, ...)` — column names go into the alias clause.

src/builder/update.ts:55

  • The Oracle .returning() unsupported error string is duplicated across insert/update/delete builders. Keeping this message in sync across mutation types is easy to miss and can lead to inconsistent behavior and tests.
    const oracle = tableCls.database.dialect === "oracle";
    if (oracle && returning) {
      throw new Error(".returning() is not yet supported on oracle mutations");
    }

@ryanrasti
ryanrasti merged commit a414b3c into main Aug 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants