stor update
fails with single-quote (apostrophe) in string (but stor insert
works)ย #14909
Open
Description
Describe the bug
Attempting to use a string in the stor update --update-record
with an embedded single quote fails. However, inserting that same record into a row entry works fine.
How to reproduce
stor reset # Optional
stor create --table-name test_table --columns { id: int, value: str }
# => โญโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฎ
# => โ test_table โ [list 0 items] โ
# => โฐโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโฏ
# We can insert new row with a string with a single quote just fine
stor insert -t test_table --data-record {
id: 1
value: "Doesn't fail"
}
# => โญโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
# => โ โ โญโโโโฌโโโโโฌโโโโโโโโโโโโโโโฎ โ
# => โ test_table โ โ # โ id โ value โ โ
# => โ โ โโโโโผโโโโโผโโโโโโโโโโโโโโโค โ
# => โ โ โ 0 โ 1 โ Doesn't fail โ โ
# => โ โ โฐโโโโดโโโโโดโโโโโโโโโโโโโโโฏ โ
# => โฐโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
# We can update the row as long as it doesn't have a single quote
stor update -t test_table --where-clause 'id = 1' --update-record {
id: 1
value: "This also works"
}
# => โญโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
# => โ โ โญโโโโฌโโโโโฌโโโโโโโโโโโโโโโโโโฎ โ
# => โ test_table โ โ # โ id โ value โ โ
# => โ โ โโโโโผโโโโโผโโโโโโโโโโโโโโโโโโค โ
# => โ โ โ 0 โ 1 โ This also works โ โ
# => โ โ โฐโโโโดโโโโโดโโโโโโโโโโโโโโโโโโฏ โ
# => โฐโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
# But an update with a single-quote in the string will fail
stor update -t test_table --where-clause 'id = 1' --update-record {
id: 1
value: "But this doesn't work"
}
# => Error:
# => ร Failed to open SQLite connection in memory from update
# => โญโ[source:1:1]
# => 1 โ nu
# => ยท โฒ
# => ยท โฐโโ near "t": syntax error in UPDATE test_table SET id = 1, value = 'But this doesn't work' WHERE id = 1 at offset 54
# => โฐโโโโ
Note also that the span is incorrect - It points to a span start of 0 apparently, meaning it loads view files | get 0
(a.k.a. the source
entry)
Expected behavior
Record is updated properly.
Configuration
key | value |
---|---|
version | 0.101.1 |
major | 0 |
minor | 101 |
patch | 1 |
branch | main |
commit_hash | 299453e |
build_os | linux-x86_64 |
build_target | x86_64-unknown-linux-gnu |
rust_version | rustc 1.82.0 (f6e511eec 2024-10-15) |
rust_channel | 1.82.0-x86_64-unknown-linux-gnu |
cargo_version | cargo 1.82.0 (8f40fc59f 2024-08-21) |
build_time | 2025-01-24 09:22:03 -05:00 |
build_rust_channel | release |
allocator | mimalloc |
features | default, sqlite, trash |
installed_plugins | formats 0.101.0, gstat 0.101.1 |