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

database/sql driver: Quote named parameter strings #481

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

brandur
Copy link
Contributor

@brandur brandur commented Jul 30, 2024

Fixes a problem reported in #478 in which during a job list, strings
aren't properly quoted before being sent to Postgres.

This is a bit of an unfortunate problem that stems from the driver being
unable to take advantage of Pgx's named parameter system, nor
database/sql's sql.Named system (because neither Pgx nor lib/pq
implement it), which required a rough implementation of a custom named
parameter system that uses string find/replace.

Here, handle a number of possible argument types that JobList might
support and make sure that the driver sends them to Postgres in an
appropriate format, making sure to quote strings and escape subquotes
they may have contained.

This is all still a little rough and something more robust would
definitely be nice, but this should all be input from River's job
module, so it doesn't need to have the most robust implementation ever.

Fixes #481.

brandur added a commit that referenced this pull request Jul 30, 2024
Fixes a problem reported in #478 in which during a job list, strings
aren't properly quoted before being sent to Postgres.

This is a bit of an unfortunate problem that stems from the driver being
unable to take advantage of Pgx's named parameter system, nor
`database/sql`'s `sql.Named` system (because neither Pgx nor `lib/pq`
implement it), which required a rough implementation of a custom named
parameter system that uses string find/replace.

Here, handle a number of possible argument types that `JobList` might
support and make sure that the driver sends them to Postgres in an
appropriate format, making sure to quote strings and escape subquotes
they may have contained.

This is all still a little rough and something more robust would
definitely be nice, but this should all be input from River's job
module, so it doesn't need to have the most robust implementation ever.

Fixes #481.
@brandur brandur force-pushed the brandur-quote-named-param-strings branch from 2544b51 to f7b264d Compare July 30, 2024 00:36
brandur added a commit that referenced this pull request Jul 30, 2024
Fixes a problem reported in #478 in which during a job list, strings
aren't properly quoted before being sent to Postgres.

This is a bit of an unfortunate problem that stems from the driver being
unable to take advantage of Pgx's named parameter system, nor
`database/sql`'s `sql.Named` system (because neither Pgx nor `lib/pq`
implement it), which required a rough implementation of a custom named
parameter system that uses string find/replace.

Here, handle a number of possible argument types that `JobList` might
support and make sure that the driver sends them to Postgres in an
appropriate format, making sure to quote strings and escape subquotes
they may have contained.

This is all still a little rough and something more robust would
definitely be nice, but this should all be input from River's job
module, so it doesn't need to have the most robust implementation ever.

Fixes #481.
@brandur brandur force-pushed the brandur-quote-named-param-strings branch from f7b264d to 6ea55ae Compare July 30, 2024 00:48
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Include `pending` state in `JobListParams` by default so pending jobs are included in `JobList` / `JobListTx` results.
- Include `pending` state in `JobListParams` by default so pending jobs are included in `JobList` / `JobListTx` results. [PR #477](https://github.com/riverqueue/river/pull/477).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh, thanks for adding this, forgot to after I opened the PR

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries!

brandur added a commit that referenced this pull request Jul 31, 2024
Fixes a problem reported in #478 in which during a job list, strings
aren't properly quoted before being sent to Postgres.

This is a bit of an unfortunate problem that stems from the driver being
unable to take advantage of Pgx's named parameter system, nor
`database/sql`'s `sql.Named` system (because neither Pgx nor `lib/pq`
implement it), which required a rough implementation of a custom named
parameter system that uses string find/replace.

Here, handle a number of possible argument types that `JobList` might
support and make sure that the driver sends them to Postgres in an
appropriate format, making sure to quote strings and escape subquotes
they may have contained.

This is all still a little rough and something more robust would
definitely be nice, but this should all be input from River's job
module, so it doesn't need to have the most robust implementation ever.

Fixes #481.
@brandur brandur force-pushed the brandur-quote-named-param-strings branch from 6ea55ae to 8691e45 Compare July 31, 2024 00:22
brandur added a commit that referenced this pull request Jul 31, 2024
Fixes a problem reported in #478 in which during a job list, strings
aren't properly quoted before being sent to Postgres.

This is a bit of an unfortunate problem that stems from the driver being
unable to take advantage of Pgx's named parameter system, nor
`database/sql`'s `sql.Named` system (because neither Pgx nor `lib/pq`
implement it), which required a rough implementation of a custom named
parameter system that uses string find/replace.

Here, handle a number of possible argument types that `JobList` might
support and make sure that the driver sends them to Postgres in an
appropriate format, making sure to quote strings and escape subquotes
they may have contained.

This is all still a little rough and something more robust would
definitely be nice, but this should all be input from River's job
module, so it doesn't need to have the most robust implementation ever.

Fixes #481.
@brandur brandur force-pushed the brandur-quote-named-param-strings branch from 8691e45 to 0151ebf Compare July 31, 2024 00:24
Fixes a problem reported in #478 in which during a job list, strings
aren't properly quoted before being sent to Postgres.

This is a bit of an unfortunate problem that stems from the driver being
unable to take advantage of Pgx's named parameter system, nor
`database/sql`'s `sql.Named` system (because neither Pgx nor `lib/pq`
implement it), which required a rough implementation of a custom named
parameter system that uses string find/replace.

Here, handle a number of possible argument types that `JobList` might
support and make sure that the driver sends them to Postgres in an
appropriate format, making sure to quote strings and escape subquotes
they may have contained.

This is all still a little rough and something more robust would
definitely be nice, but this should all be input from River's job
module, so it doesn't need to have the most robust implementation ever.

Fixes #481.
@brandur brandur force-pushed the brandur-quote-named-param-strings branch from 0151ebf to 18dfd69 Compare July 31, 2024 00:28
@brandur
Copy link
Contributor Author

brandur commented Jul 31, 2024

thx!

@brandur brandur merged commit a9cc6e6 into master Jul 31, 2024
10 checks passed
@brandur brandur deleted the brandur-quote-named-param-strings branch July 31, 2024 14:10
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