Skip to content
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

Fix prepared statements #455

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

fabianfett
Copy link
Collaborator

Motivation

Currently Prepared Statements only work if they only use bindings that have the PostgresDataType text. The reason for this is that text has the same representation in text and binary form. For this reason Postgres does not need to know the datatype upfront.

Changes

  • Allow users to specify the bindings datatypes explicitly. Fallback to unspecified.
  • If binding datatypes are unspecified infer them from the first provided bindings
  • Allow users to override the prepared statement name
  • Add integration test that validates the behavior

@fabianfett fabianfett added the semver-minor Adds new public API. label Feb 21, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (69ccfdf) 62.28% compared to head (ba9349d) 62.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #455      +/-   ##
==========================================
+ Coverage   62.28%   62.29%   +0.01%     
==========================================
  Files         124      125       +1     
  Lines        9937     9946       +9     
==========================================
+ Hits         6189     6196       +7     
- Misses       3748     3750       +2     
Files Coverage Δ
...nection State Machine/ConnectionStateMachine.swift 63.48% <100.00%> (ø)
...tion State Machine/ExtendedQueryStateMachine.swift 79.59% <100.00%> (ø)
...urces/PostgresNIO/New/PostgresChannelHandler.swift 84.80% <100.00%> (+0.02%) ⬆️
Sources/PostgresNIO/New/PreparedStatement.swift 100.00% <100.00%> (ø)
Sources/PostgresNIO/New/PSQLTask.swift 77.77% <83.33%> (-0.35%) ⬇️
...es/PostgresNIO/Connection/PostgresConnection.swift 42.28% <40.00%> (-0.20%) ⬇️

... and 1 file with indirect coverage changes

@fabianfett fabianfett merged commit 0679ede into vapor:main Feb 21, 2024
12 of 13 checks passed
@fabianfett fabianfett deleted the ff-fix-prepared-statements branch February 21, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor Adds new public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants