Commit 461772ff authored by maryo's avatar maryo

Fix parameter list expansion inside PostgreSQL arrays

parent c446c311
...@@ -35,7 +35,7 @@ class SQLParserUtils ...@@ -35,7 +35,7 @@ class SQLParserUtils
const ESCAPED_SINGLE_QUOTED_TEXT = "'(?:[^'\\\\]|\\\\'?|'')*'"; const ESCAPED_SINGLE_QUOTED_TEXT = "'(?:[^'\\\\]|\\\\'?|'')*'";
const ESCAPED_DOUBLE_QUOTED_TEXT = '"(?:[^"\\\\]|\\\\"?)*"'; const ESCAPED_DOUBLE_QUOTED_TEXT = '"(?:[^"\\\\]|\\\\"?)*"';
const ESCAPED_BACKTICK_QUOTED_TEXT = '`(?:[^`\\\\]|\\\\`?)*`'; const ESCAPED_BACKTICK_QUOTED_TEXT = '`(?:[^`\\\\]|\\\\`?)*`';
const ESCAPED_BRACKET_QUOTED_TEXT = '\[(?:[^\]])*\]'; const ESCAPED_BRACKET_QUOTED_TEXT = '(?<!\bARRAY)\[(?:[^\]])*\]';
/** /**
* Gets an array of the placeholders in an sql statements as keys and their positions in the query string. * Gets an array of the placeholders in an sql statements as keys and their positions in the query string.
......
...@@ -34,6 +34,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase ...@@ -34,6 +34,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
array("SELECT '?' FROM foo WHERE bar = ?", true, array(32)), array("SELECT '?' FROM foo WHERE bar = ?", true, array(32)),
array("SELECT `?` FROM foo WHERE bar = ?", true, array(32)), // Ticket DBAL-552 array("SELECT `?` FROM foo WHERE bar = ?", true, array(32)), // Ticket DBAL-552
array("SELECT [?] FROM foo WHERE bar = ?", true, array(32)), array("SELECT [?] FROM foo WHERE bar = ?", true, array(32)),
array('SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, ARRAY[?])', true, array(56)), // Ticket GH-2295
array("SELECT 'Doctrine\DBAL?' FROM foo WHERE bar = ?", true, array(45)), // Ticket DBAL-558 array("SELECT 'Doctrine\DBAL?' FROM foo WHERE bar = ?", true, array(45)), // Ticket DBAL-558
array('SELECT "Doctrine\DBAL?" FROM foo WHERE bar = ?', true, array(45)), // Ticket DBAL-558 array('SELECT "Doctrine\DBAL?" FROM foo WHERE bar = ?', true, array(45)), // Ticket DBAL-558
array('SELECT `Doctrine\DBAL?` FROM foo WHERE bar = ?', true, array(45)), // Ticket DBAL-558 array('SELECT `Doctrine\DBAL?` FROM foo WHERE bar = ?', true, array(45)), // Ticket DBAL-558
...@@ -53,6 +54,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase ...@@ -53,6 +54,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
array('SELECT foo::date as date FROM Foo WHERE bar > :start_date AND baz > :start_date', false, array(46 => 'start_date', 68 => 'start_date')), // Ticket GH-259 array('SELECT foo::date as date FROM Foo WHERE bar > :start_date AND baz > :start_date', false, array(46 => 'start_date', 68 => 'start_date')), // Ticket GH-259
array('SELECT `d.ns:col_name` FROM my_table d WHERE `d.date` >= :param1', false, array(57 => 'param1')), // Ticket DBAL-552 array('SELECT `d.ns:col_name` FROM my_table d WHERE `d.date` >= :param1', false, array(57 => 'param1')), // Ticket DBAL-552
array('SELECT [d.ns:col_name] FROM my_table d WHERE [d.date] >= :param1', false, array(57 => 'param1')), // Ticket DBAL-552 array('SELECT [d.ns:col_name] FROM my_table d WHERE [d.date] >= :param1', false, array(57 => 'param1')), // Ticket DBAL-552
array('SELECT * FROM foo WHERE jsonb_exists_any(foo.bar, ARRAY[:foo])', false, array(56 => 'foo')), // Ticket GH-2295
array( array(
<<<'SQLDATA' <<<'SQLDATA'
SELECT * FROM foo WHERE SELECT * FROM foo WHERE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment