Skip to content

Support OracleSQL importer#775

Merged
huydo862003 merged 17 commits intomasterfrom
feat/oracle-sql-importer
Nov 18, 2025
Merged

Support OracleSQL importer#775
huydo862003 merged 17 commits intomasterfrom
feat/oracle-sql-importer

Conversation

@huydo862003
Copy link
Copy Markdown
Contributor

@huydo862003 huydo862003 commented Nov 4, 2025

Summary

  • [@dbml/core] Support OracleSQL importer.
  • DBX-4596

In the below table, the following notation is used:

  • ✅: Supported.
  • 🤷🏼‍♂️: Invalid SQL in a specific flavor.
  • ❓: Valid SQL in a specific flavor & our importer can still generates output but ignores this syntax.
  • ❌: Valid SQL in a specific flavor, but our importer fails to generate any output.
SQL syntax OracleSQL
1. INSERT statement Link
1.a. Basic INSERT ... VALUES
1.b. INSERT ... SELECT
1.c. Multi-row INSERT 🤷🏼‍♂️
1.d. Common table expression (WITH clause)
1.e. Target table alias
1.f. INSERT ... RETURNING/INSERT … OUTPUT
1.g. INSERT ... ON CONFLICT (UPSERT)/INSERT ... ON DUPLICATE KEY/INSERT … IGNORE 🤷🏼‍♂️
1.h. INSERT OVERWRITE 🤷🏼‍♂️
1.i. Multi-table INSERT
1.j. Conditional multi-table INSERT (WHEN/FIRST/ALL)
6. CREATE TABLE Link
6.a. Basic syntax
6.a.i. Enumerated data type 🤷🏼‍♂️ (but supported in Oracle 23ai)
6.a.ii. Data type of the form name(...)
6.a.iii. Data type of the form name[...] 🤷🏼‍♂️
6.b. PRIMARY KEY
6.b.i. Inline PRIMARY KEY
6.b.ii. Out-of-line PRIMARY KEY
6.b.iii. Composite PRIMARY KEY
6.b.iv. Named PRIMARY KEY
6.b.v. Other options (deferrable, etc.) ❓(ignore the options)
6.c. FOREIGN KEY
6.c.i. Inline FOREIGN KEY
6.c.ii. Out-of-line FOREIGN KEY
6.c.iii. Composite FOREIGN KEY
6.c.iv. Named FOREIGN KEY
6.c.v. ON UPDATE 🤷🏼‍♂️
6.c.vi. ON DELETE
6.c.vii. Other options (deferrable, etc.)
6.d. UNIQUE
6.d.i. Inline UNIQUE
6.d.ii. Out-of-line UNIQUE
6.d.iii. Composite UNIQUE
6.d.iv. Named UNIQUE
6.d.v. Other options (deferrable, etc)
6.d.vi. NULLS NOT DISTINCT
6.d.vii. UNIQUE KEY/UNIQUE INDEX 🤷🏼‍♂️
6.e. CHECK
6.e.i. Inline CHECK
6.e.ii. Out-of-line CHECK
6.e.iii. Named CHECK
6.e.iv. Other options (enforcement control, etc.)
6.f. DEFAULT values
6.f.i. Inline DEFAULT
6.f.ii. Out-of-line DEFAULT 🤷🏼‍♂️
6.f.iii. Functional DEFAULT
6.f.iv. Named DEFAULT 🤷🏼‍♂️
6.g. NULL
6.h. NOT NULL
6.h.i. Inline NOT NULL
6.h.ii. Out-of-line NOT NULL 🤷🏼‍♂️
6.h.iii. Named NOT NULL 🤷🏼‍♂️
6.h.iv. Other options (deferrable, etc.)
6.i. Indexes
6.i.i. Inline indexes 🤷🏼‍♂️
6.i.ii. Out-of-line indexes
6.i.iii. Named indexes
6.i.iv. Multi-column indexes
6.i.v. CLUSTERED/ NONCLUSTERED 🤷🏼‍♂️
6.i.vi. FULLTEXT 🤷🏼‍♂️
6.i.vii. SPATIAL 🤷🏼‍♂️
6.i.viii. Other options
6.i.ix. USING HASH/BTREE 🤷🏼‍♂️
6.j. Auto-increment
6.j.i. AUTO_INCREMENT 🤷🏼‍♂️
6.j.ii. SERIAL/BIG SERIAL 🤷🏼‍♂️
6.j.iii. IDENTITY 🤷🏼‍♂️
6.j.iv. Increment range
6.j.v GENERATED ... AS IDENTITY
6.k. Computed column
6.l. TEMPORARY tables ❓(No indication of temporary table)
6.m. CREATE TABLE AS SELECT (CTAS)
6.n. Comments
6.n.i. Table comments
6.n.ii. Column comments
6.o. Other options (inheritance, UNLOGGED, paritition, collate, etc.)
7. ALTER TABLE Link
7.a. ADD COLUMN
7.a.i. Type
7.a.ii. DEFAULT
7.a.iii. NOT NULL
7.a.iv. NULL
7.a.v. CHECK
7.a.vi. UNIQUE
7.a.vii. FOREIGN KEY
7.a.viii. PRIMARY KEY
7.a.ix. AUTOINCREMENT/SERIAL/BIGSERIAL/IDENTITY/GENERATED AS IDENTITY
7.a.x. Computed column
7.b. DROP COLUMN
7.c. ALTER COLUMN / MODIFY COLUMN
7.c.i. COMMENT 🤷🏼‍♂️
7.c.ii. Others
7.d. RENAME COLUMN
7.e. ADD CONSTRAINT
7.e.i. DEFAULT
7.e.ii. NOT NULL
7.e.iii. NULL
7.e.iv. named CHECK
7.e.v. unnamed CHECK
7.e.vi. named UNIQUE
7.e.vii. unnamed UNIQUE
7.e.viii. named PRIMARY KEY
7.e.ix. unnamed PRIMARY KEY
7.e.x. named FOREIGN KEY
7.e.xi. unnamed FOREIGN KEY
7.g. DROP CONSTRAINT
7.h. ALTER CONSTRAINT
7.i. RENAME TABLE
7.j. SET SCHEMA
7.k. ALTER INDEX 🤷🏼‍♂️
7.l. DROP INDEX 🤷🏼‍♂️
7.m. SET COMMENT/COMMENT = 🤷🏼‍♂️
7.n. ADD INDEX 🤷🏼‍♂️
8. DROP TABLE Link
8.a. Basic syntax
9. CREATE INDEX Link
9.a. Basic syntax
9.b. Composite index
9.c. Named index
9.d. UNIQUE index
9.e. Partial/Filtered index ❓ (ignore)
9.f. BTREE/HASH/GIST/BRIN/… index 🤷🏼‍♂️
9.g. INCLUDE columns 🤷🏼‍♂️
9.h. CLUSTERED/NONCLUSTERED 🤷🏼‍♂️
9.i. Functional index
9.j. FULLTEXT/SPATIAL index 🤷🏼‍♂️
9.k. COLLATE
9.l. COMMENT
9.m. NULLS LAST/FIRST 🤷🏼‍♂️
9.n. ASC/DESC
10. DROP INDEX Link
10.a. Basic syntax
11. ALTER INDEX Link
11.a. RENAME
11.b. ALTER COLUMN

Issue

(issue link here)

Lasting Changes (Technical)

(please list down: code changes/things that have wide-effect; new libraries/functions added that can be used by others; examples below)

  • (Added class EmailValidator to validate email address' validity)
  • (Added Tenant#is_trial? check)

Checklist

Please check directly on the box once each of these are done

  • Documentation (if necessary)
  • Tests (integration test/unit test)
  • Integration Tests Passed
  • Code Review

@huydo862003 huydo862003 marked this pull request as draft November 4, 2025 06:46
@huydo862003 huydo862003 force-pushed the feat/oracle-sql-importer branch 9 times, most recently from 8329b78 to 6d04628 Compare November 6, 2025 08:20
@huydo862003 huydo862003 marked this pull request as ready for review November 6, 2025 08:23
@huydo862003 huydo862003 force-pushed the feat/oracle-sql-importer branch from 6d04628 to 6579ba4 Compare November 6, 2025 08:24
@huydo862003 huydo862003 added the PR: New Feature 🚀 A type of pull request used for changelog categories label Nov 6, 2025
@huydo862003 huydo862003 force-pushed the feat/oracle-sql-importer branch 3 times, most recently from a19772a to b57efb7 Compare November 6, 2025 09:25
@huydo862003 huydo862003 force-pushed the feat/oracle-sql-importer branch from b6d1895 to d9c79ee Compare November 7, 2025 07:49
@huydo862003 huydo862003 force-pushed the feat/oracle-sql-importer branch from ae0792c to 805f384 Compare November 17, 2025 04:48
// : REFERENCES tableview_name paren_column_list? (ON DELETE (CASCADE | SET NULL_))?
// ;
visitReferences_clause (ctx) {
if (!ctx.paren_column_list()) throw createCompilerError(ctx.tableview_name(), 'Importing a foreign key with implicit referenced columns is not supported');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we ignore the reference clauses that don't have column list instead of throwing error?

Copy link
Copy Markdown
Contributor Author

@huydo862003 huydo862003 Nov 18, 2025

Choose a reason for hiding this comment

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

I don't think we should ignore the reference clauses. It should be explicit that we doesn't support implicit reference clauses. Imagine the 2 scenarios:

  • If we throw an unsupported error:
    1. The user uses dbml importer to import into DBML with some implicit reference clauses.
    2. The dbml importer reports that implicit reference clauses are unsupported.
    3. The user goes back and replaces all implicit reference clauses with explicit clauses.
    4. The user try import again.
      -> A little annoying but the user knows right away what's the problem is.
  • If we just ignore them:
    1. The user uses dbml importer to import into DBML with some implicit reference clauses.
    2. dbml importer succeeds without any notice.
    3. The user if notices this would be confused. Worse, if the user doesn't notice this, they would totally miss it and may only find it some days later.
    4. The user either edits the output dbml or if they can guess that the implicit references are what causes the issues, they may edits the original sql.
      -> Annoying and confusing.

I think a decent reconcillation is to not throw an error but notify them about the implicit references. However, this would not work in dbdiagram.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In these cases, I think it would be better if we can throw warning to let the user known, but not necessarily an full blown error that cause the import to fail. But this can be reworked in later PRs

Comment thread packages/dbml-cli/src/cli/index.js
@huydo862003 huydo862003 force-pushed the feat/oracle-sql-importer branch 2 times, most recently from 42b6c32 to e5fedd3 Compare November 18, 2025 09:07
@huydo862003 huydo862003 force-pushed the feat/oracle-sql-importer branch from e5fedd3 to 913a985 Compare November 18, 2025 09:12
@huydo862003 huydo862003 merged commit 90b39ca into master Nov 18, 2025
3 of 4 checks passed
@huydo862003 huydo862003 deleted the feat/oracle-sql-importer branch November 18, 2025 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: New Feature 🚀 A type of pull request used for changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants