Add support for combined (multiple) primary keys#154
Open
EmilianoBruni wants to merge 59 commits intoknex:masterfrom
Open
Add support for combined (multiple) primary keys#154EmilianoBruni wants to merge 59 commits intoknex:masterfrom
EmilianoBruni wants to merge 59 commits intoknex:masterfrom
Conversation
…aml to prettier ignore
… key return types
…ons and clean up commented code
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR add support for combined (multiple) primary keys.
If there is only one primary key for a given table, it return as a string as in current version.
If table has a combined (multiple) primary keys, they are return as an array of string. (Version previous 3.1.0 doesn't support combined pks and in this case it returned the first pk only)
As side effect this PR fix a wrong detection of foreign keys in CockroachDB where always returned pk of first table.
I also update library to latest, fix github action and moved from npm to pnpm.
All tests for
pass locally (
pnpm test) and in GitHub ActionMore...
This pull request introduces several improvements and changes to the project, focusing on enhanced support for composite primary keys, migration to pnpm, improved development and CI workflows, and updated documentation. The most significant update is the addition of support for tables with multiple-column (composite) primary keys across all supported dialects. The CI and development environment have also been modernized for better reliability and developer experience.
Primary key/composite key support:
primarymethod for all major dialects (cockroachdb.ts,mssql.ts,mysql.ts,oracledb.ts,postgres.ts). The return type is nowstring | string[] | null, returning an array for composite keys, a string for single keys (backward compatibility), or null if none.README.mdto explain the new behavior ofprimary, including usage examples and notes on backward compatibility.Development and build tooling improvements:
.prettierignore, Dockerfiles, and the development container configuration (.devcontainer.json,docker/dev/Dockerfile,docker/docker-compose.vscode.yml).docker-compose.ymltodocker/docker-compose.yml, updated seed file paths, and upgraded CockroachDB image version.CI/CD workflow enhancements:
workflow_dispatchfor testing.Other improvements:
flatteninsqlite.tsto use the correct lodash subpath.README.mdto mention CockroachDB support.Let me know if you have questions about any of these changes or want to discuss the new composite primary key support in detail!