-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Optimize Drizzle validator types #4424
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
AndriiSherman
merged 9 commits into
drizzle-team:main
from
L-Mario564:validators-optimization
May 9, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a3c16bd
Optimize drizzle-arktype types
L-Mario564 830263c
More drizzle-arktype type optimizations
L-Mario564 454c750
Set new baselines for type benchmarks
L-Mario564 65a6850
Change Buffer schema definition for drizzle-arktype
L-Mario564 c677624
Optimize drizzle-zod types
L-Mario564 0bd32f2
Optimize drizzle-valibot types
L-Mario564 49e6b70
Optimize drizzle-typebox types
L-Mario564 783f446
Merge remote-tracking branch 'upstream/main' into validators-optimiza…
L-Mario564 82d2213
Merge branch 'main' into validators-optimization
AndriiSherman 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { bench, setup } from '@ark/attest'; | ||
| import { type } from 'arktype'; | ||
| import { boolean, integer, pgTable, text } from 'drizzle-orm/pg-core'; | ||
| import { createSelectSchema } from '~/index.ts'; | ||
|
|
||
| const users = pgTable('users', { | ||
| id: integer().primaryKey(), | ||
| firstName: text().notNull(), | ||
| middleName: text(), | ||
| lastName: text().notNull(), | ||
| age: integer().notNull(), | ||
| admin: boolean().notNull().default(false), | ||
| }); | ||
|
|
||
| const teardown = setup(); | ||
|
|
||
| bench('select schema', () => { | ||
| return createSelectSchema(users); | ||
| }).types([13129, 'instantiations']); | ||
|
|
||
| bench('select schema with refinements', () => { | ||
| return createSelectSchema(users, { | ||
| firstName: (t) => t.atMostLength(100), | ||
| middleName: (t) => t.atMostLength(100), | ||
| lastName: (t) => t.atMostLength(100), | ||
| age: type.number.atLeast(1), | ||
| }); | ||
| }).types([21631, 'instantiations']); | ||
|
|
||
| teardown(); |
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,7 +1,6 @@ | ||
| export { bufferSchema, jsonSchema, literalSchema } from './column.ts'; | ||
| export * from './column.types.ts'; | ||
| export * from './schema.ts'; | ||
| export type { BuildSchema } from './schema.types.internal.ts'; | ||
| export * from './schema.types.internal.ts'; | ||
| export * from './schema.types.ts'; | ||
| export * from './utils.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
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 |
|---|---|---|
|
|
@@ -9,5 +9,5 @@ | |
| "~/*": ["src/*"] | ||
| } | ||
| }, | ||
| "include": ["src", "*.ts"] | ||
| "include": ["src", "*.ts", "benchmarks"] | ||
| } | ||
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.
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.
Hey @L-Mario564, I just wanted to let you know that I did a quick test for this specific schema in my codebase where I encountered the problem, and it does solve it. Thank you very much!