Skip to content

Commit 6031c5c

Browse files
committed
Normalize multi-column UNIQUE error format from Turso
1 parent c02d5e5 commit 6031c5c

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,15 @@ jobs:
553553
"\t\t\t// Normalise Turso-specific decoration to SQLite format.\n"
554554
"\t\t\t$msg = str_replace( 'Runtime error: ', '', $msg );\n"
555555
"\t\t\t$msg = preg_replace( '/ \\(19\\)$/', '', $msg );\n"
556+
"\t\t\t// UNIQUE constraint failed: t.(a, b) -> t.a, t.b\n"
557+
"\t\t\t$msg = preg_replace_callback(\n"
558+
"\t\t\t\t'/(\\w+)\\.\\(([^)]+)\\)/',\n"
559+
"\t\t\t\tfunction ( $m ) {\n"
560+
"\t\t\t\t\t$cols = array_map( 'trim', explode( ',', $m[2] ) );\n"
561+
"\t\t\t\t\treturn implode( ', ', array_map( fn( $c ) => $m[1] . '.' . $c, $cols ) );\n"
562+
"\t\t\t\t},\n"
563+
"\t\t\t\t$msg\n"
564+
"\t\t\t);\n"
556565
"\t\t\tthrow $this->new_driver_exception( $msg, $e->getCode(), $e );"
557566
)
558567
assert old in src, 'rethrow block not found'

0 commit comments

Comments
 (0)