Skip to content

Commit 04aecc7

Browse files
committed
Patch Turso to look up scalar functions case-insensitively
The driver's translator emits e.g. THROW(...) in uppercase, but the UDFs are registered with lowercase names like 'throw'. Turso's extension registry stores the name as-is and connection.rs does a case-sensitive HashMap lookup, so 32 tests fail with 'no such function: THROW'. Normalise to lowercase at both register and lookup sites.
1 parent 25cc97b commit 04aecc7

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

.github/workflows/phpunit-tests-turso.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,29 @@ jobs:
105105
print(f'patched {n} sqlite3_column_* functions')
106106
PY
107107
108+
# SQLite looks up function names case-insensitively, but Turso's
109+
# extension registry stores names as-is and connection.rs looks
110+
# them up with HashMap::get directly. The driver's translator emits
111+
# e.g. THROW(...) uppercase, so 32 tests fail with
112+
# "no such function: THROW" even though we registered "throw".
113+
# Normalise to lowercase at both register and lookup sites.
114+
python3 - <<'PY_FN_CASE'
115+
p = 'core/connection.rs'
116+
s = open(p).read()
117+
old = 'self.functions.get(name).cloned()'
118+
new = 'self.functions.get(&name.to_lowercase()).cloned()'
119+
assert old in s, 'resolve_function lookup not found'
120+
open(p, 'w').write(s.replace(old, new, 1))
121+
122+
p = 'core/ext/mod.rs'
123+
s = open(p).read()
124+
old = '(*ext_ctx.syms).functions.insert(\n name_str.clone(),'
125+
new = '(*ext_ctx.syms).functions.insert(\n name_str.to_lowercase(),'
126+
assert old in s, 'register_scalar_function insert not found'
127+
open(p, 'w').write(s.replace(old, new, 1))
128+
print('patched function-name case (register + resolve)')
129+
PY_FN_CASE
130+
108131
echo '--- Patched stub! macro ---'
109132
sed -n '/macro_rules! stub/,/^}$/p' sqlite3/src/lib.rs
110133

0 commit comments

Comments
 (0)