Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a2e8df6
feat: improve relationship cardinality and enrich with optionality
huydo862003 Jul 1, 2026
6465cc3
feat: support lexing and parsing relationship op
huydo862003 Jul 1, 2026
cef0cbf
feat: support optional relationship op in isRelationshipOp
huydo862003 Jul 1, 2026
14dbf4a
fix: add ? to the lex case of operators & add tests
huydo862003 Jul 1, 2026
ac22a33
fix: lint issues
huydo862003 Jul 1, 2026
939a6fd
feat: make metadata optional ref aware
huydo862003 Jul 1, 2026
7c59ef5
feat: add methods to metadata to return cardinalities
huydo862003 Jul 1, 2026
5f68c4d
feat: refactor the flow of constraints checking to be more methodical
huydo862003 Jul 1, 2026
c76d4d4
feat: integrate relationship op into @dbml/core
huydo862003 Jul 1, 2026
698cacb
feat: support exporting optional ref in DbmlExporter
huydo862003 Jul 1, 2026
c945551
feat: export getMultiplicites
huydo862003 Jul 1, 2026
c5a7016
feat: support relationship op in sql exporter
huydo862003 Jul 1, 2026
26d9cde
fix: respect original export ref order
huydo862003 Jul 1, 2026
2af4ad8
fix: revert big breaking change regarding addDoubleQuoteIfNeeded
huydo862003 Jul 1, 2026
823fa63
test: add space after :
huydo862003 Jul 1, 2026
f74727f
fix: revert big breaking change regarding space after :
huydo862003 Jul 1, 2026
dc822c6
refactor: more concise optional ref test
huydo862003 Jul 1, 2026
cb1fca1
feat: add exporter tests for optional refs
huydo862003 Jul 1, 2026
ecc4490
feat: adjust cardinality in endpoint
huydo862003 Jul 1, 2026
fe269e0
test: add tests for optional ref importer to DBML
huydo862003 Jul 1, 2026
5e3778b
fix: adjust cardinality in normalized model
huydo862003 Jul 1, 2026
90ae93a
test: add tests for optional ref importer to DBML
huydo862003 Jul 1, 2026
9f50cea
test: fix failed tests
huydo862003 Jul 1, 2026
87323b9
feat: add warnings for logical and physical ref mismatch
huydo862003 Jul 1, 2026
42481b6
test: update cli test
huydo862003 Jul 1, 2026
4494399
v8.3.2-9.0.0-optional-ref.0
huydo862003 Jul 3, 2026
01feeb4
v9.0.0-optional-ref.0
huydo862003 Jul 3, 2026
a73fd23
feat: re-export som cardinalities and helper functions
huydo862003 Jul 3, 2026
95687af
v9.0.0-optional-ref.1
huydo862003 Jul 3, 2026
0835f7a
feat: add CompileInfo
huydo862003 Jul 3, 2026
c2ed040
fix: split nullable() and isNotNullSet()
huydo862003 Jul 3, 2026
7d15f1d
feat: add code action provider
huydo862003 Jul 3, 2026
f41fb3b
feat: implement code actions
huydo862003 Jul 3, 2026
80c0de1
fix: filter out relevant code actions
huydo862003 Jul 3, 2026
5924d61
fix: make code action provider multifile aware
huydo862003 Jul 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dbml-playground/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dbml/playground",
"version": "8.3.1",
"version": "9.0.0-optional-ref.1",
"description": "Interactive playground for debugging and visualizing the DBML parser pipeline",
"author": "Holistics <dev@holistics.io>",
"license": "Apache-2.0",
Expand All @@ -25,8 +25,8 @@
"format": "prettier --write src/"
},
"dependencies": {
"@dbml/core": "^8.3.1",
"@dbml/parse": "^8.3.1",
"@dbml/core": "^9.0.0-optional-ref.1",
"@dbml/parse": "^9.0.0-optional-ref.0",
"@phosphor-icons/vue": "^2.2.0",
"floating-vue": "^5.2.2",
"lodash-es": "^4.17.21",
Expand Down
1 change: 1 addition & 0 deletions dbml-playground/src/components/editor/dbml_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export async function setupDbmlServices (compiler: Compiler): Promise<void> {
monaco.languages.registerDefinitionProvider(languageId, services.definitionProvider as any);
monaco.languages.registerReferenceProvider(languageId, services.referenceProvider as any);
monaco.languages.registerCompletionItemProvider(languageId, services.autocompletionProvider as any);
monaco.languages.registerCodeActionProvider(languageId, services.codeActionProvider as any);
}

export function updateDiagnosticMarkers (model: monaco.editor.ITextModel): void {
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "8.3.1",
"version": "9.0.0-optional-ref.1",
"npmClient": "yarn",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,4 @@ Ref "fk_order":"dbo"."orders"."order_id" < "dbo"."order_items"."order_id" [updat

Ref "fk_user":"dbo"."users"."user_id" < "dbo"."orders"."user_id" [update: cascade, delete: cascade]

Ref "fk_gender":"dbo"."gender_reference"."value" < "dbo"."user_define_data_types"."gender"
Ref "fk_gender":"dbo"."gender_reference"."value" <? "dbo"."user_define_data_types"."gender"
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,4 @@ Ref "fk_detail_items_orders":"orders"."order_id" < "order_items"."order_id" [del

Ref "fk_detail_items_products":"products"."id" < "order_items"."product_id"

Ref "fk_order_user":"users"."user_id" < "orders"."user_id" [delete: set null]
Ref "fk_order_user":"users"."user_id" <? "orders"."user_id" [delete: set null]
Original file line number Diff line number Diff line change
Expand Up @@ -400,20 +400,20 @@ Table "SPECIAL_DATA_TYPES" {
"UROWID_SIZED" urowid(100)
}

Ref "FK_SELF_REF":"SELF_REF_FK"."ID" < "SELF_REF_FK"."PARENT_ID" [delete: set null]
Ref "FK_SELF_REF":"SELF_REF_FK"."ID" <? "SELF_REF_FK"."PARENT_ID" [delete: set null]

Ref "FK_CHILD_PARENT":"FK_PARENT"."ID" < "FK_CHILD"."PARENT_ID" [delete: cascade]

Ref "FK_COMPOSITE_SELF":"COMPOSITE_SELF_REF".("DEPT_ID", "EMP_ID") < "COMPOSITE_SELF_REF".("PARENT_DEPT_ID", "PARENT_EMP_ID") [delete: set null]
Ref "FK_COMPOSITE_SELF":"COMPOSITE_SELF_REF".("DEPT_ID", "EMP_ID") <? "COMPOSITE_SELF_REF".("PARENT_DEPT_ID", "PARENT_EMP_ID") [delete: set null]

Ref "FK_ALTER_PARENT":"ALTER_FK_PARENT"."ID" < "ALTER_FK_CHILD"."PARENT_ID" [delete: cascade]
Ref "FK_ALTER_PARENT":"ALTER_FK_PARENT"."ID" <? "ALTER_FK_CHILD"."PARENT_ID" [delete: cascade]

Ref "FK_ALTER_SELF":"ALTER_SELF_REF"."ID" < "ALTER_SELF_REF"."PARENT_ID" [delete: set null]
Ref "FK_ALTER_SELF":"ALTER_SELF_REF"."ID" <? "ALTER_SELF_REF"."PARENT_ID" [delete: set null]

Ref "FK_ALTER_COMPOSITE":"ALTER_COMPOSITE_FK_PARENT".("DEPT_ID", "EMP_ID") < "ALTER_COMPOSITE_FK_CHILD".("REF_DEPT_ID", "REF_EMP_ID")
Ref "FK_ALTER_COMPOSITE":"ALTER_COMPOSITE_FK_PARENT".("DEPT_ID", "EMP_ID") <? "ALTER_COMPOSITE_FK_CHILD".("REF_DEPT_ID", "REF_EMP_ID")

Ref "FK_REF_SIMPLE":"REF_SIMPLE_PARENT"."ID" < "REF_SIMPLE_CHILD"."PARENT_ID"
Ref "FK_REF_SIMPLE":"REF_SIMPLE_PARENT"."ID" <? "REF_SIMPLE_CHILD"."PARENT_ID"

Ref "FK_REF_COMPOSITE":"REF_COMPOSITE_PARENT".("KEY1", "KEY2") < "REF_COMPOSITE_CHILD".("FK1", "FK2")
Ref "FK_REF_COMPOSITE":"REF_COMPOSITE_PARENT".("KEY1", "KEY2") <? "REF_COMPOSITE_CHILD".("FK1", "FK2")

Ref "FK_ALTER_COMP_SELF":"ALTER_COMP_SELF_REF".("DEPT_ID", "EMP_ID") < "ALTER_COMP_SELF_REF".("PARENT_DEPT_ID", "PARENT_EMP_ID")
Ref "FK_ALTER_COMP_SELF":"ALTER_COMP_SELF_REF".("DEPT_ID", "EMP_ID") <? "ALTER_COMP_SELF_REF".("PARENT_DEPT_ID", "PARENT_EMP_ID")
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Table "table_with_composite_primary_and_unique_indexes" {
}
}

Ref "fk_authornationality":"authors".("authorid", "nationalityid") < "books".("authorid", "nationalityid") [delete: cascade]
Ref "fk_authornationality":"authors".("authorid", "nationalityid") <? "books".("authorid", "nationalityid") [delete: cascade]

Ref "fk_order":"orders"."order_id" < "order_items"."order_id" [delete: cascade]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ Table "CodeDef" {
}
}

Ref "fk__CodeDef__ParentCdKey__CodeDef__CdKey":"CodeDef"."CdKey" < "CodeDef"."ParentCdKey"
Ref "fk__CodeDef__ParentCdKey__CodeDef__CdKey":"CodeDef"."CdKey" <? "CodeDef"."ParentCdKey"

Ref "fk__CodeDef__UserMasterKeyLastEditedBy__UserMaster_UserMasterKey":"UserMaster"."UserMasterKey" < "CodeDef"."UserMasterKeyLastEditedBy"
Ref "fk__CodeDef__UserMasterKeyLastEditedBy__UserMaster_UserMasterKey":"UserMaster"."UserMasterKey" <? "CodeDef"."UserMasterKeyLastEditedBy"
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ Table "countries" {
"continent_name" varchar(255)
}

Ref:"orders"."id" < "order_items"."order_id"
Ref:"orders"."id" <? "order_items"."order_id"

Ref:"products"."id" < "order_items"."product_id"
Ref:"products"."id" <? "order_items"."product_id"

Ref:"countries"."code" < "users"."country_code"
Ref:"countries"."code" <? "users"."country_code"

Ref:"countries"."code" < "merchants"."country_code"
Ref:"countries"."code" <? "merchants"."country_code"

Ref:"merchants"."id" < "products"."merchant_id"

Ref:"users"."id" < "merchants"."admin_id"
Ref:"users"."id" <? "merchants"."admin_id"
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Table "countries" {
"continent_name" varchar(255)
}

Ref:"orders"."id" < "order_items"."order_id"
Ref:"orders"."id" <? "order_items"."order_id"

Ref:"products"."id" < "order_items"."product_id"
Ref:"products"."id" <? "order_items"."product_id"

Ref:"countries"."code" < "users"."country_code"
Ref:"countries"."code" <? "users"."country_code"

Ref:"countries"."code" < "merchants"."country_code"
Ref:"countries"."code" <? "merchants"."country_code"

Ref:"merchants"."id" < "products"."merchant_id"

Ref:"users"."id" < "merchants"."admin_id"
Ref:"users"."id" <? "merchants"."admin_id"

Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ Table "task_hours" {
"hours_worked" NUMBER(5,2)
}

Ref "fk_emp_dept":"departments"."dept_id" < "employees"."department_id"
Ref "fk_emp_dept":"departments"."dept_id" <? "employees"."department_id"

Ref "fk_dept_location":"locations"."location_id" < "departments"."location_id"
Ref "fk_dept_location":"locations"."location_id" <? "departments"."location_id"

Ref "fk_loc_country":"countries"."country_code" < "locations"."country_code"
Ref "fk_loc_country":"countries"."country_code" <? "locations"."country_code"

Ref "fk_emp_manager":"employees"."emp_id" < "employees"."manager_id"
Ref "fk_emp_manager":"employees"."emp_id" <? "employees"."manager_id"

Ref "fk_dept_manager":"employees"."emp_id" < "departments"."manager_id"
Ref "fk_dept_manager":"employees"."emp_id" <? "departments"."manager_id"

Ref:"departments"."dept_id" < "projects"."dept_id"
Ref:"departments"."dept_id" <? "projects"."dept_id"

Ref:"employees"."emp_id" < "assignments"."emp_id"
Ref:"employees"."emp_id" <? "assignments"."emp_id"

Ref:"projects"."project_id" < "assignments"."project_id"
Ref:"projects"."project_id" <? "assignments"."project_id"

Ref "fk_task_hours_project_task":"project_tasks".("project_id", "task_id") < "task_hours".("project_id", "task_id")
Ref "fk_task_hours_project_task":"project_tasks".("project_id", "task_id") ?<? "task_hours".("project_id", "task_id")

Ref "fk_proj_lead_emp":"employees"."emp_id" < "projects"."lead_emp_id"
Ref "fk_proj_lead_emp":"employees"."emp_id" <? "projects"."lead_emp_id"

Ref "fk_proj_backup_emp":"employees"."emp_id" < "projects"."backup_emp_id"
Ref "fk_proj_backup_emp":"employees"."emp_id" <? "projects"."backup_emp_id"

Ref "fk_task_assigned_emp":"employees"."emp_id" < "project_tasks"."assigned_emp_id"
Ref "fk_task_assigned_emp":"employees"."emp_id" <? "project_tasks"."assigned_emp_id"
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ Table "countries" {
"continent_name" varchar
}

Ref:"orders"."id" < "order_items"."order_id"
Ref:"orders"."id" <? "order_items"."order_id"

Ref:"products"."id" < "order_items"."product_id"
Ref:"products"."id" <? "order_items"."product_id"

Ref:"countries"."code" < "users"."country_code"
Ref:"countries"."code" <? "users"."country_code"

Ref:"countries"."code" < "merchants"."country_code"
Ref:"countries"."code" <? "merchants"."country_code"

Ref:"merchants"."id" < "products"."merchant_id"

Ref:"users"."id" < "merchants"."admin_id"
Ref:"users"."id" <? "merchants"."admin_id"
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ Table "countries" {
"continent_name" varchar
}

Ref:"orders"."id" < "order_items"."order_id"
Ref:"orders"."id" <? "order_items"."order_id"

Ref:"products"."id" < "order_items"."product_id"
Ref:"products"."id" <? "order_items"."product_id"

Ref:"countries"."code" < "users"."country_code"
Ref:"countries"."code" <? "users"."country_code"

Ref:"countries"."code" < "merchants"."country_code"
Ref:"countries"."code" <? "merchants"."country_code"

Ref:"merchants"."id" < "products"."merchant_id"

Ref:"users"."id" < "merchants"."admin_id"
Ref:"users"."id" <? "merchants"."admin_id"
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ Table "comment_on_product" {
}
}

Ref:"orders"."id" < "order_items"."order_id"
Ref:"orders"."id" <? "order_items"."order_id"

Ref:"products"."id" < "order_items"."product_id"
Ref:"products"."id" <? "order_items"."product_id"

Ref:"countries"."code" < "users"."country_code"
Ref:"countries"."code" <? "users"."country_code"

Ref:"countries"."code" < "merchants"."country_code"
Ref:"countries"."code" <? "merchants"."country_code"

Ref:"merchants"."id" < "products"."merchant_id"

Ref:"users"."id" < "merchants"."admin_id"
Ref:"users"."id" <? "merchants"."admin_id"

Original file line number Diff line number Diff line change
Expand Up @@ -446,29 +446,29 @@ Table "floor" {
"getdate" int
}

Ref:"HP_TEST"."CUSTOMERS"."CUSTOMER_ID" < "HP_TEST"."ORDERS"."CUSTOMER_ID"
Ref:"HP_TEST"."CUSTOMERS"."CUSTOMER_ID" <? "HP_TEST"."ORDERS"."CUSTOMER_ID"

Ref:"HP_TEST"."ORDERS"."ORDER_ID" < "HP_TEST"."ORDER_ITEMS"."ORDER_ID"
Ref:"HP_TEST"."ORDERS"."ORDER_ID" <? "HP_TEST"."ORDER_ITEMS"."ORDER_ID"

Ref:"HP_TEST"."PRODUCTS"."PRODUCT_ID" < "HP_TEST"."ORDER_ITEMS"."PRODUCT_ID"
Ref:"HP_TEST"."PRODUCTS"."PRODUCT_ID" <? "HP_TEST"."ORDER_ITEMS"."PRODUCT_ID"

Ref:"TEST_2024_06_28_10_01_ZQMIMY"."ONE".("BAR", "FOO") < "TEST_2024_06_28_10_01_ZQMIMY"."TWO".("XYZ", "ABC")
Ref:"TEST_2024_06_28_10_01_ZQMIMY"."ONE".("BAR", "FOO") <? "TEST_2024_06_28_10_01_ZQMIMY"."TWO".("XYZ", "ABC")

Ref:"TEST_2024_06_28_10_01_ZQMIMY"."ONE"."FOO" < "TEST_2024_06_28_10_01_ZQMIMY"."TWO"."QWE"
Ref:"TEST_2024_06_28_10_01_ZQMIMY"."ONE"."FOO" <? "TEST_2024_06_28_10_01_ZQMIMY"."TWO"."QWE"

Ref:"T_OUT_2"."C2" < "T_OUT_3"."C3"
Ref:"T_OUT_2"."C2" <? "T_OUT_3"."C3"

Ref:"T_OUT_5"."C2" < "T_OUT_6"."C3"
Ref:"T_OUT_5"."C2" <? "T_OUT_6"."C3"

Ref:"T_OUT_5"."C2" < "T_CONSTRAINT_3"."C3"
Ref:"T_OUT_5"."C2" <? "T_CONSTRAINT_3"."C3"

Ref:"T_OUT_5"."C2" < "T_CONSTRAINT_4"."C3"
Ref:"T_OUT_5"."C2" <? "T_CONSTRAINT_4"."C3"

Ref:"T_OUT_5"."C2" < "T_CONSTRAINT_5"."C3"
Ref:"T_OUT_5"."C2" <? "T_CONSTRAINT_5"."C3"

Ref:"T_OUT_5"."C2" < "T_CONSTRAINT_6"."C3"
Ref:"T_OUT_5"."C2" <? "T_CONSTRAINT_6"."C3"

Ref:"T_OUT_5"."C2" < "T_CONSTRAINT_8"."C3"
Ref:"T_OUT_5"."C2" <? "T_CONSTRAINT_8"."C3"

Ref:"T_OUT_5"."C2" < "T_CONSTRAINT_9"."C3"
Ref:"T_OUT_5"."C2" <? "T_CONSTRAINT_9"."C3"

10 changes: 5 additions & 5 deletions packages/dbml-cli/__tests__/sql2dbml/filename stdout/stdout.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ Table "countries" {
"continent_name" varchar
}

Ref:"orders"."id" < "order_items"."order_id"
Ref:"orders"."id" <? "order_items"."order_id"

Ref:"products"."id" < "order_items"."product_id"
Ref:"products"."id" <? "order_items"."product_id"

Ref:"countries"."code" < "users"."country_code"
Ref:"countries"."code" <? "users"."country_code"

Ref:"countries"."code" < "merchants"."country_code"
Ref:"countries"."code" <? "merchants"."country_code"

Ref:"merchants"."id" < "products"."merchant_id"

Ref:"users"."id" < "merchants"."admin_id"
Ref:"users"."id" <? "merchants"."admin_id"

Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ Table "rental" {
"last_update" timestamp
}

Ref:"store"."id" < "staff"."store_id"
Ref:"store"."id" <? "staff"."store_id"

Ref:"staff"."id" < "store"."manager_staff_id"
Ref:"staff"."id" <? "store"."manager_staff_id"

Ref:"staff"."id" < "payment"."staff_id"
Ref:"staff"."id" <? "payment"."staff_id"

Ref:"rental"."id" < "payment"."rental_id"
Ref:"rental"."id" <? "payment"."rental_id"

Ref:"staff"."id" < "rental"."staff_id"
Ref:"staff"."id" <? "rental"."staff_id"
Table "country" {
"id" int [pk]
"country" varchar(255)
Expand Down Expand Up @@ -88,11 +88,11 @@ Table "customer" {
}
}

Ref:"country"."id" < "city"."country_id"
Ref:"country"."id" <? "city"."country_id"

Ref:"city"."id" < "address"."city_id"
Ref:"city"."id" <? "address"."city_id"

Ref:"address"."id" < "customer"."address_id"
Ref:"address"."id" <? "customer"."address_id"
Table "category" {
"id" int [pk]
"name" varchar(255)
Expand Down Expand Up @@ -155,16 +155,16 @@ Table "inventory" {
"last_update" timestamp
}

Ref:"category"."id" < "film_category"."category_id"
Ref:"category"."id" <? "film_category"."category_id"

Ref:"inventory"."film_id" < "film_text"."film_id"
Ref:"inventory"."film_id" ?<? "film_text"."film_id"

Ref:"language"."id" < "film"."language_id"
Ref:"language"."id" <? "film"."language_id"

Ref:"language"."id" < "film"."original_language_id"
Ref:"language"."id" <? "film"."original_language_id"

Ref:"film"."id" < "film_actor"."film_id"
Ref:"film"."id" <? "film_actor"."film_id"

Ref:"actor"."id" < "film_actor"."actor_id"
Ref:"actor"."id" <? "film_actor"."actor_id"

Ref:"film"."id" < "inventory"."film_id"
Ref:"film"."id" <? "inventory"."film_id"
Loading
Loading