-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[bun:sqlite] Support unprefixed bindings, safe integers / BigInt, as(Class)
#11887
Merged
Conversation
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
❌ @Jarred-Sumner, your commit has failing tests :( 💪 1 failing tests Darwin AARCH64
💻 1 failing tests Darwin x64 baseline
💻 1 failing tests Darwin x64
🐧💪 1 failing tests Linux AARCH64
🐧🖥 1 failing tests Linux x64 baseline
🐧🖥 1 failing tests Linux x64
🪟💻 1 failing tests Windows x64 baseline
🪟💻 1 failing tests Windows x64
|
…y` with `strict`
$
, @
, :
prefix in valuesas(Class)
The failing sql-raw test should probably be deleted. It is now difficult to use the bindings directly that way, and we shouldn't really expose it anyway. |
cirospaciari
requested changes
Jun 16, 2024
Electroid
reviewed
Jun 16, 2024
Electroid
reviewed
Jun 16, 2024
cirospaciari
approved these changes
Jun 17, 2024
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.
What does this PR do?
Fixes #5661
Fixes #5261
Fixes #6591
Fixes #5256 (bigint)
Fixes #1536
Fixes #8284
Fixes #3284
This adds a new
strict?: boolean
to theDatabase
constructor which lets you omit the$
,@
, or:
prefix when binding values to prepared statements.After:
Before:
safeIntegers: true
When
safeIntegers
istrue
,bun:sqlite
will return integers asbigint
types:When
safeIntegers
istrue
,bun:sqlite
will throw an error if abigint
value in a bound parameter exceeds 64 bits:.as(Class)
- attach methods & getters/setters to resultsUse
.as(Class)
to run a query and get back the results as instances of a class.As a performance optimization, the class constructor is not called, default initializers are not run, and private fields are not accessible. This is more like using
Object.create
thannew
. The class's prototype is assigned to the object, methods are attached, and getters/setters are set up, but the constructor is not called.The database columns are set as properties on the class instance.
How did you verify your code works?
There are tests