mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-26 19:04:32 +02:00
Fix _decode_default_value to unescape doubled single quotes in string defaults (#811)
* Fix _decode_default_value to unescape doubled single quotes in string defaults SQLite stores string defaults with single quotes doubled (e.g. DEFAULT 'O''Brien' is stored as the literal "'O''Brien'" in sqlite_master). The previous code stripped the outer quotes with value[1:-1] but never converted '' back to ', so default_values returned the raw escaped form instead of the true string value. * Test for doubled single quotes in string defaults
This commit is contained in:
parent
a7b734946f
commit
6a456830ca
2 changed files with 13 additions and 2 deletions
|
|
@ -5108,8 +5108,8 @@ def resolve_extracts(
|
|||
|
||||
def _decode_default_value(value: str) -> object:
|
||||
if value.startswith("'") and value.endswith("'"):
|
||||
# It's a string
|
||||
return value[1:-1]
|
||||
# It's a string; unescape doubled single quotes
|
||||
return value[1:-1].replace("''", "'")
|
||||
if value.isdigit():
|
||||
# It's an integer
|
||||
return int(value)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue