-
-
Notifications
You must be signed in to change notification settings - Fork 502
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sql): add native support for generated columns (#4884)
To use generated columns, you can either use the `generated` option, or specify it as part of the `columnType`: ```ts @entity() export class User { @PrimaryKey() id!: number; @Property({ length: 50 }) firstName!: string; @Property({ length: 50 }) lastName!: string; @Property<User>({ length: 100, generated: cols => `(concat(${cols.firstName}, ' ', ${cols.lastName})) stored` }) fullName!: string & Opt; @Property({ columnType: `varchar(100) generated always as (concat(first_name, ' ', last_name)) virtual` }) fullName2!: string & Opt; } ``` To use a generated identity column in PostgreSQL, set the `generated` option to `identity`: > To allow providing the value explicitly, use `generated: 'by default as identity'`. ```ts @entity() export class User { @PrimaryKey({ generated: 'identity' }) id!: number; } ```
- Loading branch information
Showing
45 changed files
with
999 additions
and
199 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
Oops, something went wrong.