Escape PostgreSQL options
Properly escape PostgreSQL options containing spaces and backslash characters as specified under https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-OPTIONS.
Fixes #2027
Is this a breaking change?
~~No, this change fixes behavior that I consider a minor edge case.~~
Yes,
anyone who's already manually escaping options will get different, likely incorrect, results after this patch
This is technically a breaking behavior change as well, because anyone who's already manually escaping options will get different, likely incorrect, results after this patch.
This should also document that the strings will be escaped: https://github.com/launchbadge/sqlx/blob/e474be6d4b4f7b8a1bbeb65363ef53015feebc47/sqlx-postgres/src/options/mod.rs#L496-L504
Alternatively, we don't do this internally but instead expose PgEscapeOption and direct people to use it. That would be backwards-compatible.
Alternatively, we don't do this internally but instead expose PgEscapeOption and direct people to use it. That would be backwards-compatible.
This would leak implementation details and keep a foot gun around, so I’d caution against that.
This would leak implementation details and keep a foot gun around, so I’d caution against that.
- It's a detail of the underlying protocol, which can be important to understand.
- We could emit a warning log if someone provides a string that isn't properly escaped.
- I have learned that silent changes to behavior tend to trip people up regardless, because not everyone reads the CHANGELOG or reads it thoroughly. Hyrum's Law has always held true.
- Users who aren't prepared to upgrade to a new major version won't be able to benefit.
If you're fine waiting for this to hit 0.9.0, then it doesn't matter.