From 874ba342938d8eea83c61a6cfe2f47aa3008ba78 Mon Sep 17 00:00:00 2001 From: Hari K T Date: Mon, 28 Feb 2022 18:15:03 +0530 Subject: [PATCH 1/3] Add failing test for #177 --- tests/Parser/AbstractParserTest.php | 20 +++++++++++++++++ tests/Parser/PgsqlParserTest.php | 35 +++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/tests/Parser/AbstractParserTest.php b/tests/Parser/AbstractParserTest.php index f3fcc13..efbf2f0 100644 --- a/tests/Parser/AbstractParserTest.php +++ b/tests/Parser/AbstractParserTest.php @@ -148,4 +148,24 @@ public function testIssue107() $this->assertEquals($statement, $sql); $this->assertEquals($values, $parameters); } + + public function testIn() + { + $parameters = ['types' => [1, 2]]; + $sql = <<rebuild($sql, $parameters); + + $expectedSql = << 1, + 'types_1' => 2 + ]; + + $this->assertEquals($expectedSql, $statement); + $this->assertEquals($expectedParameters, $values); + } } diff --git a/tests/Parser/PgsqlParserTest.php b/tests/Parser/PgsqlParserTest.php index 6795739..5b0397c 100644 --- a/tests/Parser/PgsqlParserTest.php +++ b/tests/Parser/PgsqlParserTest.php @@ -92,4 +92,39 @@ public function testInvalidPlaceholderName() list ($statement, $values) = $this->rebuild($sql, $parameters); $this->assertEquals($sql, $statement); } + + public function testIssue177() + { + $parameters = ['types' => [1, 2]]; + // AND + $sql = << '{\"is_hidden\":false}'::jsonb +SQL; + list ($statement, $values) = $this->rebuild($sql, $parameters); + + $expectedSql = << '{\"is_hidden\":false}'::jsonb +SQL; + + $expectedParameters = [ + 'types_0' => 1, + 'types_1' => 2 + ]; + + $this->assertEquals($expectedSql, $statement); + $this->assertEquals($expectedParameters, $values); + + // change order + $sql = << '{\"is_hidden\":false}'::jsonb AND type in (:types) +SQL; + list ($statement, $values) = $this->rebuild($sql, $parameters); + + $expectedSql = << '{\"is_hidden\":false}'::jsonb AND type in (:types_0, :types_1) +SQL; + + $this->assertEquals($expectedSql, $statement); + $this->assertEquals($expectedParameters, $values); + } } From 9b3410999bccb3ca5e8f947b04afe59ac5f8984b Mon Sep 17 00:00:00 2001 From: Hari K T Date: Mon, 28 Feb 2022 18:25:14 +0530 Subject: [PATCH 2/3] Remove commented code --- tests/Parser/PgsqlParserTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Parser/PgsqlParserTest.php b/tests/Parser/PgsqlParserTest.php index 5b0397c..9b6acbf 100644 --- a/tests/Parser/PgsqlParserTest.php +++ b/tests/Parser/PgsqlParserTest.php @@ -96,7 +96,6 @@ public function testInvalidPlaceholderName() public function testIssue177() { $parameters = ['types' => [1, 2]]; - // AND $sql = << '{\"is_hidden\":false}'::jsonb SQL; From ed7a4218ca49c6e7af558c7010c1ada559e54964 Mon Sep 17 00:00:00 2001 From: Hari K T Date: Tue, 1 Mar 2022 12:43:58 +0530 Subject: [PATCH 3/3] Add timeout --- .github/workflows/continuous-integration.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index df36d75..017286a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -10,6 +10,8 @@ jobs: runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: matrix: operating-system: