Repository navigation
Escape bytearray contents as bytes in string literals - #817
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #817 +/- ##
==========================================
+ Coverage 88.86% 91.83% +2.96%
==========================================
Files 7 7
Lines 548 686 +138
==========================================
+ Hits 487 630 +143
+ Misses 61 56 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Passing
bytearray(b'ab')as a query parameter currently sends the Python textbytearray(b'ab')to the server. Escape the underlying two bytes so the parameter behaves likeb'ab'. This also applies tobytearraysubclasses. On free-threaded builds, the copy is protected by the bytearray's critical section.The new low-level tests failed before the fix and passed with the rebuilt CPython 3.14 wheel (32 tests passed locally). The updated database test checks the returned value with
binary_prefixenabled and disabled and is left to CI. Ruff andgit diff --checkpassed.Related discussion in #816.
Summary by CodeRabbit
bytearrayvalues are now handled consistently withbyteswhen creating SQL literals, including values containing quotes, null bytes, or backslashes. Subclasses are processed from their byte contents rather than their string representation.string_literalhandles byte-like values versus other objects.