diff --git a/src/AbstractDmlQuery.php b/src/AbstractDmlQuery.php index 3edb7a4..b7c5702 100644 --- a/src/AbstractDmlQuery.php +++ b/src/AbstractDmlQuery.php @@ -45,7 +45,7 @@ abstract class AbstractDmlQuery extends AbstractQuery */ public function hasCols() { - return (bool) $this->col_values; + return !empty($this->col_values); } /** diff --git a/tests/AbstractQueryTest.php b/tests/AbstractQueryTest.php index a7eee4c..14d9b87 100644 --- a/tests/AbstractQueryTest.php +++ b/tests/AbstractQueryTest.php @@ -73,5 +73,8 @@ public function testBindValues() $expect = array('foo' => 'bar', 'baz' => 'dib', 'zim' => 'gir'); $actual = $this->query->getBindValues(); $this->assertSame($expect, $actual); + + $this->query->resetBindValues(); + $this->assertEmpty($this->query->getBindValues()); } } diff --git a/tests/Common/SelectTest.php b/tests/Common/SelectTest.php index 02e76d7..ba6790c 100644 --- a/tests/Common/SelectTest.php +++ b/tests/Common/SelectTest.php @@ -960,4 +960,28 @@ public function testUnionSelectCanHaveSameAliasesInDifferentSelects() $actual = (string) $select->getStatement(); $this->assertSameSql($expected, $actual); } + + public function testResetUnion() + { + $select = $this->query + ->cols(array( + '...' + )) + ->from('a') + ->union() + ->cols(array( + '...' + )) + ->from('b'); + + // should remove all prior queries and just leave the last. + $select->resetUnions(); + $expected = 'SELECT + ... + FROM + <>'; + + $actual = (string) $select->getStatement(); + $this->assertSameSql($expected, $actual); + } } diff --git a/tests/Common/UpdateTest.php b/tests/Common/UpdateTest.php index de4996d..9b40919 100644 --- a/tests/Common/UpdateTest.php +++ b/tests/Common/UpdateTest.php @@ -42,4 +42,12 @@ public function testCommon() ); $this->assertSame($expect, $actual); } + + public function testHasCols() + { + $this->query->table('t1'); + $this->assertFalse($this->query->hasCols()); + $this->query->cols(['c1', 'c2']); + $this->assertTrue($this->query->hasCols()); + } } diff --git a/tests/FakeQuery.php b/tests/FakeQuery.php deleted file mode 100644 index cc179cc..0000000 --- a/tests/FakeQuery.php +++ /dev/null @@ -1,20 +0,0 @@ -