File tree Expand file tree Collapse file tree 5 files changed +32
-14
lines changed
tests/Flow/PgQuery/Tests/Unit Expand file tree Collapse file tree 5 files changed +32
-14
lines changed Original file line number Diff line number Diff line change @@ -35,19 +35,11 @@ jobs:
3535 brew install autoconf automake libtool protobuf protobuf-c
3636
3737 - name : Build libpg_query and extension
38- working-directory : src/extension/pg-query-parser
38+ working-directory : src/extension/pg-query-ext
3939 run : |
4040 make clean || true
4141 make build
4242
4343 - name : Run extension tests
44- working-directory : src/extension/pg-query-parser
44+ working-directory : src/extension/pg-query-ext
4545 run : make test
46-
47- - name : Install composer dependencies
48- working-directory : src/extension/pg-query-parser
49- run : composer install --no-interaction
50-
51- - name : Run PHP tests
52- working-directory : src/extension/pg-query-parser
53- run : php -d extension=./ext/modules/pg_query.so vendor/bin/phpunit
Original file line number Diff line number Diff line change @@ -81,8 +81,8 @@ make install
8181From the Flow PHP monorepo root:
8282
8383``` bash
84- # Enter Nix shell with build tools
85- nix-shell --arg with-pg-query-build-tools true
84+ # Enter Nix shell with pg_query extension loaded and build tools available
85+ nix-shell --arg with-pg-query-ext true
8686
8787# Navigate to extension directory
8888cd src/extension/pg-query-ext
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ PHP_MINFO_FUNCTION(pg_query)
7171 php_info_print_table_start ();
7272 php_info_print_table_header (2 , "pg_query support" , "enabled" );
7373 php_info_print_table_row (2 , "Version" , PHP_PG_QUERY_VERSION );
74- php_info_print_table_row (2 , "libpg_query version" , "16-5 .1.0" );
74+ php_info_print_table_row (2 , "libpg_query version" , "17-6 .1.0" );
7575 php_info_print_table_end ();
7676}
7777
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public function parse(string $sql) : ParseResult
3535 try {
3636 $ json = pg_query_parse ($ sql );
3737 } catch (\RuntimeException $ e ) {
38- throw new ParserException ($ e ->getMessage ());
38+ throw new ParserException ($ e ->getMessage (), $ e -> getCode () ?: null );
3939 }
4040
4141 $ result = new ParseResult ();
Original file line number Diff line number Diff line change @@ -55,6 +55,32 @@ public function test_normalize_multiple_values() : void
5555 self ::assertStringContainsString ('$2 ' , $ normalized );
5656 }
5757
58+ public function test_parse_exception_contains_cursor_position () : void
59+ {
60+ $ parser = new Parser ();
61+
62+ try {
63+ $ parser ->parse ('SELECT * FROM ' );
64+ } catch (\Flow \PgQuery \Exception \ParserException $ e ) {
65+ self ::assertNotNull ($ e ->cursorPosition );
66+ self ::assertGreaterThan (0 , $ e ->cursorPosition );
67+
68+ return ;
69+ }
70+
71+ self ::fail ('Expected ParserException was not thrown ' );
72+ }
73+
74+ public function test_parse_invalid_sql_throws_exception () : void
75+ {
76+ $ parser = new Parser ();
77+
78+ $ this ->expectException (\Flow \PgQuery \Exception \ParserException::class);
79+ $ this ->expectExceptionMessage ('syntax error ' );
80+
81+ $ parser ->parse ('SELECT FROM WHERE ' );
82+ }
83+
5884 public function test_parse_multiple_statements () : void
5985 {
6086 $ parser = new Parser ();
You can’t perform that action at this time.
0 commit comments