Skip to content

Commit c96a268

Browse files
committed
Also patch result[2] PRAGMA assertion in testCreateTableWithDefaultExpressions
The previous patch only fixed the simple `(1 + 2)` assertion, but the test also asserts on the translated DATETIME() call expression, which Turso emits with outer parens AND a space between the function name and `(`: expected (real SQLite): DATETIME(CURRENT_TIMESTAMP, '+' || 1 || ' YEAR') actual (Turso): (DATETIME (CURRENT_TIMESTAMP, '+' || 1 || ' YEAR')) Update the assertion to match Turso's output. The result[3] '('a' || 'b')' assertion already matches Turso (real SQLite also preserves parens for that one), so it's left alone.
1 parent b23d78a commit c96a268

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,16 +1749,26 @@ jobs:
17491749
# don't need changes.
17501750
path = 'tests/WP_SQLite_Driver_Tests.php'
17511751
src = open(path).read()
1752-
old_pragma_assert = (
1753-
"\t\t$this->assertSame( '1 + 2', $result[1]['dflt_value'] );\n"
1752+
# `(1 + 2)` simple expression: Turso preserves outer parens.
1753+
old_a = "\t\t$this->assertSame( '1 + 2', $result[1]['dflt_value'] );\n"
1754+
new_a = "\t\t$this->assertSame( '(1 + 2)', $result[1]['dflt_value'] );\n"
1755+
assert old_a in src, 'PRAGMA result[1] assertion not found'
1756+
src = src.replace(old_a, new_a, 1)
1757+
# Translated DATETIME(...) call: Turso preserves outer parens AND
1758+
# inserts a space between the function name and the opening paren
1759+
# in its PRAGMA echo of the stored default expression.
1760+
old_b = (
1761+
"\t\t$this->assertSame( \"DATETIME(CURRENT_TIMESTAMP, '+' || 1 || ' YEAR')\", "
1762+
"$result[2]['dflt_value'] );\n"
17541763
)
1755-
new_pragma_assert = (
1756-
"\t\t$this->assertSame( '(1 + 2)', $result[1]['dflt_value'] );\n"
1764+
new_b = (
1765+
"\t\t$this->assertSame( \"(DATETIME (CURRENT_TIMESTAMP, '+' || 1 || ' YEAR'))\", "
1766+
"$result[2]['dflt_value'] );\n"
17571767
)
1758-
assert old_pragma_assert in src, 'PRAGMA dflt_value assertion not found'
1759-
src = src.replace(old_pragma_assert, new_pragma_assert, 1)
1768+
assert old_b in src, 'PRAGMA result[2] assertion not found'
1769+
src = src.replace(old_b, new_b, 1)
17601770
open(path, 'w').write(src)
1761-
print('patched testCreateTableWithDefaultExpressions PRAGMA expectation for Turso')
1771+
print('patched testCreateTableWithDefaultExpressions PRAGMA expectations for Turso')
17621772
PY
17631773
17641774
- name: Run PHPUnit tests against Turso DB

0 commit comments

Comments
 (0)