From 03b0939ac877537142cc0fd93c238ad982b8f91e Mon Sep 17 00:00:00 2001 From: Nghiem Anh Tuan Date: Mon, 9 Sep 2019 16:11:04 +0700 Subject: [PATCH] Version 2.0.0 --- CHANGELOG.md | 18 +++++++++--------- Query.php | 2 -- .../unit/koolreport/querybuilder/QueryTest.php | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7325d0b..4c2d448 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,15 +2,15 @@ ## Version 2.0.0 (new version) -1. Fix the selectRaw rendering -2. Adding parameters to whereRaw(), havingRaw(), orderByRaw() methods -3. Add options to set quotes for identifiers -4. Make default not use quotes for identifiers -5. SQLServer: Generate correct query for limit and offset -6. Query: Add groupByRaw() method -7. Query: Add create() static function to create query from array -8. Query: Adding toArray() function to export query to array format -9. Query: Add fill() method to quickly fill query with array +1. `Query`: Fix the selectRaw rendering +2. `Query`: Adding parameters to `whereRaw()`, `havingRaw()`, `orderByRaw()` methods +3. `SQL`: Add options to set quotes for identifiers +4. `SQL`: Make default not use quotes for identifiers +5. `SQLServer`: Generate correct query for limit and offset +6. `Query`: Add `groupByRaw()` method +7. `Query`: Add `create()` static function to create query from array +8. `Query`: Adding `toArray()` function to export query to array format +9. `Query`: Add `fill()` method to quickly fill query with array ## Version 1.5.0 diff --git a/Query.php b/Query.php index c8b4cac..202f92f 100644 --- a/Query.php +++ b/Query.php @@ -692,9 +692,7 @@ public function fill($arr) if ($arr!==null) { $arr = $this->rebuildSubQueries($arr); foreach ($arr as $key=>$value) { - if (isset($this->$key)) { $this->$key = $value; - } } } } diff --git a/tests/unit/koolreport/querybuilder/QueryTest.php b/tests/unit/koolreport/querybuilder/QueryTest.php index 5d76470..cf87ce9 100644 --- a/tests/unit/koolreport/querybuilder/QueryTest.php +++ b/tests/unit/koolreport/querybuilder/QueryTest.php @@ -67,9 +67,24 @@ public function testCreate() $query = Query::create([ "type"=>"select", "tables"=>["orders"], + "limit"=>2 ]); $sql = $query->toMySQL(); - $this->assertEquals($sql, "SELECT * FROM orders"); + $this->assertEquals("SELECT * FROM orders LIMIT 2",$sql); + } + + public function testToArray() + { + $query = Query::create([ + "type"=>"select", + "tables"=>["orders"], + "limit"=>2, + "offset"=>3, + "distinct"=>true, + "lock"=>true, + ]); + $str_arr = json_encode($query->toArray()); + $this->assertEquals("abc",$str_arr); } public function testSerialize()