Skip to content

Commit

Permalink
Fixed query logging for delete_many; added unit test for delete_many
Browse files Browse the repository at this point in the history
  • Loading branch information
tag authored and treffynnon committed Nov 26, 2012
1 parent 87b05b7 commit e2cb224
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions idiorm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,7 @@ public function delete_many() {
$this->_quote_identifier($this->_table_name),
$this->_build_where(),
));
self::_log_query($query, $this->_values);
$statement = self::$_db->prepare($query);
return $statement->execute($this->_values);
}
Expand Down
10 changes: 7 additions & 3 deletions test/test_queries.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -291,20 +291,24 @@
$expected = "DELETE FROM `widget` WHERE `id` = '1'";
Tester::check_equal("Delete data", $expected);

$widget = ORM::for_table('widget')->where_equal('age', 10)->delete_many();
$expected = "DELETE FROM `widget` WHERE `age` = '10'";
Tester::check_equal("Delete many", $expected);

// Regression tests

$widget = ORM::for_table('widget')->select('widget.*')->find_one();
$expected = "SELECT `widget`.* FROM `widget` LIMIT 1";
Tester::check_equal("Issue #12 - incorrect quoting of column wildcard", $expected);

$widget = ORM::for_table('widget')->where_raw('username LIKE "ben%"')->find_many();
$expected = 'SELECT * FROM `widget` WHERE username LIKE "ben%"';
Tester::check_equal('Issue #57 - _log_query method raises a warning when query contains "%"', $expected);

$widget = ORM::for_table('widget')->where_raw('comments LIKE "has been released?%"')->find_many();
$expected = 'SELECT * FROM `widget` WHERE comments LIKE "has been released?%"';
Tester::check_equal('Issue #57 - _log_query method raises a warning when query contains "?"', $expected);

// Tests that alter Idiorm's config are done last

ORM::configure('id_column', 'primary_key');
Expand Down

0 comments on commit e2cb224

Please sign in to comment.