Skip to content

stor update fails with single-quote (apostrophe) in string (but stor insert works)ย #14909

Open
@NotTheDr01ds

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

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions