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

Add failing test for #177 #216

Open
wants to merge 3 commits into
base: 3.x
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:

runs-on: ubuntu-latest

timeout-minutes: 10

strategy:
matrix:
operating-system:
Expand Down
20 changes: 20 additions & 0 deletions tests/Parser/AbstractParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,24 @@ public function testIssue107()
$this->assertEquals($statement, $sql);
$this->assertEquals($values, $parameters);
}

public function testIn()
{
$parameters = ['types' => [1, 2]];
$sql = <<<SQL
SELECT * FROM table WHERE id IN (:types)
SQL;
list ($statement, $values) = $this->rebuild($sql, $parameters);

$expectedSql = <<<SQL
SELECT * FROM table WHERE id IN (:types_0, :types_1)
SQL;
$expectedParameters = [
'types_0' => 1,
'types_1' => 2
];

$this->assertEquals($expectedSql, $statement);
$this->assertEquals($expectedParameters, $values);
}
}
34 changes: 34 additions & 0 deletions tests/Parser/PgsqlParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,38 @@ public function testInvalidPlaceholderName()
list ($statement, $values) = $this->rebuild($sql, $parameters);
$this->assertEquals($sql, $statement);
}

public function testIssue177()
{
$parameters = ['types' => [1, 2]];
$sql = <<<SQL
SELECT * FROM table WHERE type in (:types) AND removed = false AND data @> '{\"is_hidden\":false}'::jsonb
SQL;
list ($statement, $values) = $this->rebuild($sql, $parameters);

$expectedSql = <<<SQL
SELECT * FROM table WHERE type in (:types_0, :types_1) AND removed = false AND data @> '{\"is_hidden\":false}'::jsonb
SQL;

$expectedParameters = [
'types_0' => 1,
'types_1' => 2
];

$this->assertEquals($expectedSql, $statement);
$this->assertEquals($expectedParameters, $values);

// change order
$sql = <<<SQL
SELECT * FROM table WHERE removed = false AND data @> '{\"is_hidden\":false}'::jsonb AND type in (:types)
SQL;
list ($statement, $values) = $this->rebuild($sql, $parameters);

$expectedSql = <<<SQL
SELECT * FROM table WHERE removed = false AND data @> '{\"is_hidden\":false}'::jsonb AND type in (:types_0, :types_1)
SQL;

$this->assertEquals($expectedSql, $statement);
$this->assertEquals($expectedParameters, $values);
}
}