-
Notifications
You must be signed in to change notification settings - Fork 213
sqlite exporter #446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
sqlite exporter #446
Conversation
|
I didn't add an importer and only a simple test, but this worked for my usecase |
nguyenalter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please implement the code to export many-to-many relationships in DBML.
You can implement it similar to this function:
| static buildForeignKeyManyToMany (fieldsMap, foreignEndpointFields, refEndpointTableName, foreignEndpointTableName, refEndpointSchema, foreignEndpointSchema, model) { |
| break; | ||
|
|
||
| case 'sqlite': | ||
| res = SqliteExporter.export(normalizedModel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be best if you could use the same class name SQLiteExporter as the class definition to make it easy to debug in the future.
| static exportRefs (refIds, model, usedTableNames) { | ||
| return []; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found that SQLite does not support the ALTER TABLE ... ADD FOREIGN KEY ... syntax (see: https://www.sqlite.org/omitted.html).
I believe that we can move the relationship definitions in the CREATE TABLE ... statement.
| Table "order_items" { | ||
| "order_id" integer | ||
| "product_id" integer | ||
| "quantity" integer [default: 1] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the DBML syntax is correct, this mapping table should be defined after the products table so that when we export to SQLite, if the foreign key constraints are added in the CREATE TABLE "ORDER_ITEMS" ... statement, the exported SQL is still correct.
| static exportIndexes (indexIds, model) { | ||
| return []; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please export the indexes.
| static getTableContentArr (tableIds, model) { | ||
| const tableContentArr = tableIds.map((tableId) => { | ||
| const fieldContents = SQLiteExporter.getFieldLines(tableId, model); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function needs to export the composite primary keys. You can refer to
| const compositePKs = PostgresExporter.getCompositePKs(tableId, model); |
|
Any updates for this? |
|
Ping |
|
Hey @nguyenalter I'm picking this up — just checking in to see if you're still around to review and merge when done. |
|
@galvez Thank you for your help. Feel free to create another PR. We will be there to review it when everything is ready. |
|
any update on this? sqlite3 support will be a great feature! |
|
Would also love to know if there is anyone working on this. |
Summary
Issue
#14
#286
Lasting Changes (Technical)
Checklist
Please check directly on the box once each of these are done