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

apply TypeConverter to args, not just fields #11

Merged
merged 9 commits into from
Jun 20, 2024
Merged

Conversation

jsha
Copy link

@jsha jsha commented Jun 14, 2024

This allows using custom types in query parameters. It also allows performing custom transformations on standard types (like rounding times to the second).

This allows using custom types in query parameters. It also allows performing
custom transformations on standard types (like rounding times to the second).
@jsha jsha requested a review from a team as a code owner June 14, 2024 00:09
@jsha jsha requested a review from aarongable June 14, 2024 00:09
@jsha
Copy link
Author

jsha commented Jun 14, 2024

I also ran the new tests cases against main and confirmed they failed. One initial mystery: they failed with this error message:

Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1

Which is the same error message you'd get if, for instance, you sent a query with a ? placeholder but didn't make it a prepared statement. I think this was because the first (and only) argument was a struct, which made borp treat the query as if it was using named placeholders (instead of positional ? placeholders).

@jsha
Copy link
Author

jsha commented Jun 14, 2024

Ah, needs adjustments to run with postgres dialect and also a fix to the govulncheck test.

db.go Outdated Show resolved Hide resolved
@jsha jsha requested review from a team and beautifulentropy and removed request for a team June 17, 2024 18:52
@jsha jsha merged commit a78493c into main Jun 20, 2024
5 checks passed
@jsha jsha deleted the type-convert-args branch June 20, 2024 17:53
jsha added a commit to letsencrypt/boulder that referenced this pull request Jun 24, 2024
We believe the MariaDB query planner generates inefficient query plans
when a time index is queried using high precision (nanosecond) times.
This uses the updated borp from[1] to automatically truncate
`time.Time` and `*time.Time` in query parameters.

[1]: letsencrypt/borp#11

Part of #5437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants