Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows :dql_parameters with ARRAY_* functions #240

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ protected function customiseFunction(): void
{
$this->setFunctionPrototype('array_append(%s, %s)');
$this->addNodeMapping('StringPrimary');
$this->addNodeMapping('Literal');
$this->addNodeMapping('ArithmeticPrimary');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ protected function customiseFunction(): void
{
$this->setFunctionPrototype('array_length(%s, %s)');
$this->addNodeMapping('StringPrimary');
$this->addNodeMapping('Literal');
$this->addNodeMapping('ArithmeticPrimary');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ArrayPrepend extends BaseFunction
protected function customiseFunction(): void
{
$this->setFunctionPrototype('array_prepend(%s, %s)');
$this->addNodeMapping('Literal');
$this->addNodeMapping('ArithmeticPrimary');
$this->addNodeMapping('StringPrimary');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ protected function customiseFunction(): void
{
$this->setFunctionPrototype('array_remove(%s, %s)');
$this->addNodeMapping('StringPrimary');
$this->addNodeMapping('Literal');
$this->addNodeMapping('ArithmeticPrimary');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function customiseFunction(): void
{
$this->setFunctionPrototype('array_replace(%s, %s, %s)');
$this->addNodeMapping('StringPrimary');
$this->addNodeMapping('Literal');
$this->addNodeMapping('Literal');
$this->addNodeMapping('ArithmeticPrimary');
$this->addNodeMapping('ArithmeticPrimary');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected function getExpectedSqlStatements(): array
return [
'SELECT array_append(c0_.array1, 1989) AS sclr_0 FROM ContainsArrays c0_',
"SELECT array_append(c0_.array1, 'country') AS sclr_0 FROM ContainsArrays c0_",
'SELECT array_append(c0_.array1, ?) AS sclr_0 FROM ContainsArrays c0_',
];
}

Expand All @@ -29,6 +30,7 @@ protected function getDqlStatements(): array
return [
\sprintf('SELECT ARRAY_APPEND(e.array1, 1989) FROM %s e', ContainsArrays::class),
\sprintf("SELECT ARRAY_APPEND(e.array1, 'country') FROM %s e", ContainsArrays::class),
\sprintf('SELECT ARRAY_APPEND(e.array1, :dql_parameter) FROM %s e', ContainsArrays::class),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ protected function getExpectedSqlStatements(): array
{
return [
'SELECT array_length(c0_.array1, 1) AS sclr_0 FROM ContainsArrays c0_',
'SELECT array_length(c0_.array1, ?) AS sclr_0 FROM ContainsArrays c0_',
];
}

protected function getDqlStatements(): array
{
return [
\sprintf('SELECT ARRAY_LENGTH(e.array1, 1) FROM %s e', ContainsArrays::class),
\sprintf('SELECT ARRAY_LENGTH(e.array1, :dql_parameter) FROM %s e', ContainsArrays::class),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected function getExpectedSqlStatements(): array
return [
'SELECT array_prepend(1885, c0_.array1) AS sclr_0 FROM ContainsArrays c0_',
"SELECT array_prepend('red', c0_.array1) AS sclr_0 FROM ContainsArrays c0_",
'SELECT array_prepend(?, c0_.array1) AS sclr_0 FROM ContainsArrays c0_',
];
}

Expand All @@ -29,6 +30,7 @@ protected function getDqlStatements(): array
return [
\sprintf('SELECT ARRAY_PREPEND(1885, e.array1) FROM %s e', ContainsArrays::class),
\sprintf("SELECT ARRAY_PREPEND('red', e.array1) FROM %s e", ContainsArrays::class),
\sprintf('SELECT ARRAY_PREPEND(:dql_parameter, e.array1) FROM %s e', ContainsArrays::class),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected function getExpectedSqlStatements(): array
return [
'SELECT array_remove(c0_.array1, 1944) AS sclr_0 FROM ContainsArrays c0_',
"SELECT array_remove(c0_.array1, 'peach') AS sclr_0 FROM ContainsArrays c0_",
'SELECT array_remove(c0_.array1, ?) AS sclr_0 FROM ContainsArrays c0_',
];
}

Expand All @@ -29,6 +30,7 @@ protected function getDqlStatements(): array
return [
\sprintf('SELECT ARRAY_REMOVE(e.array1, 1944) FROM %s e', ContainsArrays::class),
\sprintf("SELECT ARRAY_REMOVE(e.array1, 'peach') FROM %s e", ContainsArrays::class),
\sprintf('SELECT ARRAY_REMOVE(e.array1, :dql_parameter) FROM %s e', ContainsArrays::class),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ protected function getExpectedSqlStatements(): array
return [
'SELECT array_replace(c0_.array1, 1939, 1957) AS sclr_0 FROM ContainsArrays c0_',
"SELECT array_replace(c0_.array1, 'green', 'mint') AS sclr_0 FROM ContainsArrays c0_",
"SELECT array_replace(c0_.array1, 'green', ?) AS sclr_0 FROM ContainsArrays c0_",
allan-simon marked this conversation as resolved.
Show resolved Hide resolved
];
}

Expand All @@ -29,6 +30,7 @@ protected function getDqlStatements(): array
return [
\sprintf('SELECT ARRAY_REPLACE(e.array1, 1939, 1957) FROM %s e', ContainsArrays::class),
\sprintf("SELECT ARRAY_REPLACE(e.array1, 'green', 'mint') FROM %s e", ContainsArrays::class),
\sprintf("SELECT ARRAY_REPLACE(e.array1, 'green', :dql_parameter) FROM %s e", ContainsArrays::class),
allan-simon marked this conversation as resolved.
Show resolved Hide resolved
];
}
}