Skip to content

Commit 3460fa3

Browse files
committed
Patch Turso stub macro so pdo_sqlite can connect
Turso's stub!() macro expands to todo!() and aborts the PHP process whenever pdo_sqlite calls an unimplemented sqlite3_* function. The first one hit is sqlite3_set_authorizer during PDO construction, so the tests can't even start. Rewrite the macro via sed before building so stubbed functions return a zeroed value of their return type (0 / SQLITE_OK for ints, NULL for pointers). This lets the driver proceed past optional calls and exercise parts of Turso that are actually implemented.
1 parent 47c9341 commit 3460fa3

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,25 @@ jobs:
3939
~/.cargo/registry
4040
~/.cargo/git
4141
turso/target
42-
key: turso-${{ runner.os }}-${{ steps.turso.outputs.tag }}
42+
key: turso-${{ runner.os }}-${{ steps.turso.outputs.tag }}-${{ hashFiles('.github/workflows/phpunit-tests-turso.yml') }}
4343

4444
- name: Clone Turso source
4545
run: git clone --depth 1 --branch '${{ steps.turso.outputs.tag }}' https://github.com/tursodatabase/turso.git
4646

47+
# Turso's stub!() macro expands to a `todo!()` that panics across the FFI
48+
# boundary and aborts the PHP process. That blocks any call into a not-yet-
49+
# implemented sqlite3_* function — e.g. sqlite3_set_authorizer, which
50+
# PHP's pdo_sqlite calls during PDO construction. Rewrite the macro so
51+
# stubbed functions return a zeroed value of their return type instead
52+
# (0 / SQLITE_OK for ints, NULL for pointers). This lets the driver reach
53+
# functions Turso does implement, so PHPUnit can produce a real report.
54+
- name: Patch Turso stub macro to not abort
55+
working-directory: turso
56+
run: |
57+
sed -i 's|todo!("{} is not implemented", stringify!($fn));|return unsafe { std::mem::zeroed() };|' sqlite3/src/lib.rs
58+
echo '--- Patched stub! macro ---'
59+
sed -n '/macro_rules! stub/,/^}$/p' sqlite3/src/lib.rs
60+
4761
- name: Build turso_sqlite3 shared library
4862
working-directory: turso
4963
run: cargo build --release -p turso_sqlite3

0 commit comments

Comments
 (0)