-
-
Notifications
You must be signed in to change notification settings - Fork 144
merge dev to main (v3.4.5) #2462
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
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8208900
fix(orm): fallback to compact temp aliases for overlong names (#2425)
pkudinov 158996c
perf(orm): use EXISTS instead of COUNT subquery for some/none/every r…
ymc9 4a99088
fix(sdk): correctly handle mixin fields for delegate model inheritance
ymc9 bd2b111
[CI] Bump version 3.4.5 (#2457)
github-actions[bot] ffa1720
fix(test): add missing dataType field in issue-2351 regression test
claude[bot] 956a64d
fix(test): correct delegate discriminator enum values to match model …
claude[bot] 00c53d7
fix(sdk): correctly handle mixin fields for delegate model inheritanc…
ymc9 2083244
fix(policy): handle DefaultInsertValueNode in createManyAndReturn (#2…
pkudinov 5aaef62
chore: address PR comments (#2463)
ymc9 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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "name": "@zenstackhq/typescript-config", | ||
| "version": "3.4.4", | ||
| "version": "3.4.5", | ||
| "private": true, | ||
| "license": "MIT" | ||
| } |
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
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
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
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
46 changes: 44 additions & 2 deletions
46
packages/orm/src/client/executor/temp-alias-transformer.ts
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 |
|---|---|---|
| @@ -1,27 +1,69 @@ | ||
| import { IdentifierNode, OperationNodeTransformer, type OperationNode, type QueryId } from 'kysely'; | ||
| import { TEMP_ALIAS_PREFIX } from '../query-utils'; | ||
|
|
||
| type TempAliasTransformerMode = 'alwaysCompact' | 'compactLongNames'; | ||
|
|
||
| type TempAliasTransformerOptions = { | ||
| mode?: TempAliasTransformerMode; | ||
| maxIdentifierLength?: number; | ||
| }; | ||
|
|
||
| /** | ||
| * Kysely node transformer that replaces temporary aliases created during query construction with | ||
| * shorter names while ensuring the same temp alias gets replaced with the same name. | ||
| */ | ||
| export class TempAliasTransformer extends OperationNodeTransformer { | ||
| private aliasMap = new Map<string, string>(); | ||
| private readonly textEncoder = new TextEncoder(); | ||
| private readonly mode: TempAliasTransformerMode; | ||
| private readonly maxIdentifierLength: number; | ||
|
|
||
| constructor(options: TempAliasTransformerOptions = {}) { | ||
| super(); | ||
| this.mode = options.mode ?? 'alwaysCompact'; | ||
| // PostgreSQL limits identifier length to 63 bytes and silently truncates overlong aliases. | ||
| const maxIdentifierLength = options.maxIdentifierLength ?? 63; | ||
| if ( | ||
| !Number.isFinite(maxIdentifierLength) || | ||
| !Number.isInteger(maxIdentifierLength) || | ||
| maxIdentifierLength <= 0 | ||
| ) { | ||
| throw new RangeError('maxIdentifierLength must be a positive integer'); | ||
| } | ||
| this.maxIdentifierLength = maxIdentifierLength; | ||
| } | ||
|
|
||
| run<T extends OperationNode>(node: T): T { | ||
| this.aliasMap.clear(); | ||
| return this.transformNode(node); | ||
| } | ||
|
|
||
| protected override transformIdentifier(node: IdentifierNode, queryId?: QueryId): IdentifierNode { | ||
| if (node.name.startsWith(TEMP_ALIAS_PREFIX)) { | ||
| if (!node.name.startsWith(TEMP_ALIAS_PREFIX)) { | ||
| return super.transformIdentifier(node, queryId); | ||
| } | ||
|
|
||
| let shouldCompact = false; | ||
| if (this.mode === 'alwaysCompact') { | ||
| shouldCompact = true; | ||
| } else { | ||
| // check if the alias name exceeds the max identifier length, and | ||
| // if so, compact it | ||
| const aliasByteLength = this.textEncoder.encode(node.name).length; | ||
| if (aliasByteLength > this.maxIdentifierLength) { | ||
| shouldCompact = true; | ||
| } | ||
| } | ||
|
|
||
| if (shouldCompact) { | ||
| let mapped = this.aliasMap.get(node.name); | ||
| if (!mapped) { | ||
| mapped = `$$t${this.aliasMap.size + 1}`; | ||
| this.aliasMap.set(node.name, mapped); | ||
| } | ||
| return IdentifierNode.create(mapped); | ||
| } else { | ||
| return super.transformIdentifier(node, queryId); | ||
| } | ||
| return super.transformIdentifier(node, queryId); | ||
| } | ||
| } |
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
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
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
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
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.