Skip to content

Commit

Permalink
Support NULL value (#42)
Browse files Browse the repository at this point in the history
* Support null value

* Fix style

* Add test

Co-authored-by: Alexander Golovenkin <alexander.golovenkin@upm.ai>
  • Loading branch information
agolovenkin and Alexander Golovenkin committed Apr 20, 2021
1 parent 8acc24d commit 637bbd2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/Query/Grammar.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ public function wrap($value)
return '`'.str_replace('`', '``', $value).'`';
} elseif (is_numeric($value)) {
return $value;
} elseif (is_null($value)) {
return 'null';
} else {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion tests/GrammarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ public function testCompileInsert()
['column' => 'value'],
['column' => 'value 2'],
['column' => 'value 3'],
['column' => null],
]);

$this->assertEquals("INSERT INTO `table` (`column`) FORMAT Values ('value'), ('value 2'), ('value 3')", $sql);
$this->assertEquals("INSERT INTO `table` (`column`) FORMAT Values ('value'), ('value 2'), ('value 3'), (null)", $sql);
}

public function testCompileInsertWithoutFrom()
Expand Down

0 comments on commit 637bbd2

Please sign in to comment.