This repository was archived by the owner on Mar 1, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 17
feat: db pull implementation #268
Merged
Merged
Changes from all commits
Commits
Show all changes
83 commits
Select commit
Hold shift + click to select a range
7675af3
feat: initial db pull implementation
svetch 5652448
fix: generate imports and attributes for zmodel-code-generator
svetch 6b16564
fix: add option to not exclude imports in loadDocument
svetch b13e15f
fix: continue work on db pull
svetch 585b5cd
fix: missing import
svetch 3c92894
fix: rewrite model generation
svetch eb8b682
feat: add ast factory
svetch 126bdcf
fix: ast factory import order
svetch 4914bae
fix: some runtime bugs
svetch 3bd3336
fix: lint fix
svetch b1633eb
fix: update zmodel code generator
svetch 3e398ba
feat: add exclude schemas option
svetch 877d3a5
feat: implement initial diff update
svetch 2f90d8f
fix: update format in zmodel code generator
svetch ed94090
fix: typo
svetch 04235d9
feat: progress on database introspection and syncing
svetch 00a1d78
fix: make ignore behave it does in prisma with no index models
svetch b4708fe
fix: lint fix
svetch f946726
feat: make all format options configurable
svetch 75ce687
fix: lint fix
svetch 9063c72
feat: Handle the database type mapping
svetch e7290ce
fix: catch up with feature updates
svetch 83c2776
fix: add sqlite e2e test and fix some bugs
svetch a420199
fix: lint fix
svetch 73d67b6
fix: formatting for e2e test schemas
svetch d1aac0f
test: run db pull e2e test also for postgres
svetch 426feb0
fix: postgres instorspection schema filter
svetch 8651f68
test: update cli tests
svetch 7e2f17d
feat(cli): Improves database introspection and syncing
svetch ea364d2
fix(cli): fixes field casing and sort issues
svetch 5b07e8f
chore(cli): remove temporary test script
svetch be99621
chore: update pnpm-lock.yaml
svetch 2e4c249
feat(cli): add MySQL support for schema introspection
svetch 71717a5
fix(cli): improve field matching logic during db pull
svetch e5de3a0
feat(cli): enhance SQLite introspection with autoincrement support
svetch 52877c3
fix(cli): refine attribute generation in db pull
svetch cf74d8b
test(cli): update db pull tests for SQLite specific behavior
svetch fc9b360
refactor(language): export ZModelServices type
svetch 459b970
fix(cli): improve sqlite introspection for autoincrement and fk names
svetch dbb1df2
feat(cli): enhance field matching logic during pull by using relation…
svetch 47d0273
refactor(cli): refine relation name generation and table syncing
svetch e318ff4
test(cli): update pull tests to reflect improved schema generation
svetch c5d87f0
test(cli): add MySQL support to test utility helpers
svetch f0cfebb
fix(cli): omit default constraint names in table sync
svetch f0d408b
fix: correctly handle default values for 'text' type in PostgreSQL
svetch b9e2840
fix: sort table indexes to ensure stable schema generation
svetch 66c0afb
refactor: dynamically determine supported db providers in CLI
svetch 057407c
test: fix typo in pull test description
svetch 6c542c5
chore(cli): remove debug artifacts and silence test logs
svetch c236ba8
fix(cli): ensure MySQL column and index ordering
svetch 6fe2df4
fix(cli): preserve column order during MySQL pull
svetch 3f983d2
refactor(cli): remove schema fields from MySQL queries
svetch 769864a
fix(cli): improve MySQL introspection and index mapping
svetch 336660e
test(cli): pass provider to default prelude in tests
svetch 52d32c8
fix(cli): improve MySQL introspection for types and defaults
svetch 2f7fe79
fix(cli): improve MySQL default value introspection
svetch 52f1ffa
test(cli): expand and reorganize db pull tests
svetch 381b1d2
refactor: restructure introspection provider interface and attribute …
svetch 34da2df
feat: modernize MySQL introspection provider
svetch 07c5804
feat: modernize PostgreSQL introspection provider
svetch 9450535
feat: modernize SQLite introspection provider
svetch 7a5071b
fix: improve relation field naming and default action handling
svetch 7910c09
feat: track imports and auto-format during db pull
svetch 7c30225
test: update pull tests to reflect naming and formatting improvements
svetch 0f999b6
fix(cli): refactor PostgreSQL type casting and fix index order
svetch c1e717d
fix(cli): filter out auto-generated MySQL indexes
svetch 27c40bd
test(cli): support datasource extras in test utils
svetch 9b54b5f
fix: address PR comments
svetch 3c48a17
fix: address PR comments
svetch 5dc900e
fix: address PR comments
svetch a3c5d62
fix: address PR comments
svetch cea210d
fix(cli): improve file path resolution in pull action
svetch b68e9ab
refactor(cli): extract and enhance name casing logic
svetch 3f0b6f2
refactor(cli): consolidate default value normalization
svetch d03c2bc
feat(cli): improve enum syncing and relation naming during pull
svetch 2922d6b
docs(cli): add documentation comments to SQL introspection queries
svetch 62cdd73
test(cli): refactor test utilities and modernize test suites
svetch 06dd907
fix(cli): improve db pull for composite FKs and MySQL uniqueness
svetch 7436243
fix: address PR comments
svetch fd463b0
fix(cli): improve SQLite introspection for untyped columns and compos…
svetch 3b2e2e3
feat(cli): pull generated/computed columns as Unsupported type
svetch af89f19
fix(cli): Use parameterized queries for MySQL introspection
svetch a264722
fix(cli): use nullish coalescing for precision check
svetch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| export function resolveNameCasing(casing: 'pascal' | 'camel' | 'snake' | 'none', originalName: string) { | ||
| let name = originalName; | ||
| const fieldPrefix = /[0-9]/g.test(name.charAt(0)) ? '_' : ''; | ||
|
|
||
| switch (casing) { | ||
| case 'pascal': | ||
| name = toPascalCase(originalName); | ||
| break; | ||
| case 'camel': | ||
| name = toCamelCase(originalName); | ||
| break; | ||
| case 'snake': | ||
| name = toSnakeCase(originalName); | ||
| break; | ||
| } | ||
|
|
||
| return { | ||
| modified: name !== originalName || fieldPrefix !== '', | ||
| name: `${fieldPrefix}${name}`, | ||
| }; | ||
| } | ||
|
|
||
| function isAllUpperCase(str: string): boolean { | ||
| return str === str.toUpperCase(); | ||
| } | ||
|
|
||
| export function toPascalCase(str: string): string { | ||
| if (isAllUpperCase(str)) return str; | ||
| return str.replace(/[_\- ]+(\w)/g, (_, c) => c.toUpperCase()).replace(/^\w/, (c) => c.toUpperCase()); | ||
| } | ||
|
|
||
| export function toCamelCase(str: string): string { | ||
| if (isAllUpperCase(str)) return str; | ||
| return str.replace(/[_\- ]+(\w)/g, (_, c) => c.toUpperCase()).replace(/^\w/, (c) => c.toLowerCase()); | ||
| } | ||
|
|
||
| export function toSnakeCase(str: string): string { | ||
| if (isAllUpperCase(str)) return str; | ||
| return str | ||
| .replace(/[- ]+/g, '_') | ||
| .replace(/([a-z0-9])([A-Z])/g, '$1_$2') | ||
| .toLowerCase(); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.