summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Holywell <[email protected]>2013-01-03 15:31:07 +0000
committerSimon Holywell <[email protected]>2013-01-03 15:31:07 +0000
commit3439ca1d152acf55ee43c81831d1098835dac58e (patch)
treec104537f4ed5b1b2fd5db07fc76c61168d461eee
parentb241439aec5dd4123e9d6d4fbf5f60364b027797 (diff)
Issue #90 When using set_expr alone it doesn't trigger query creation
-rw-r--r--README.markdown1
-rw-r--r--idiorm.php2
-rwxr-xr-xtest/test_queries.php6
3 files changed, 8 insertions, 1 deletions
diff --git a/README.markdown b/README.markdown
index f441206..4a361ba 100644
--- a/README.markdown
+++ b/README.markdown
@@ -45,6 +45,7 @@ Changelog
* Add `is_new` method - closes issue #85
* Fix last insert ID for PostgreSQL using RETURNING - closes issues #62 and #89 [[laacz](https://github.com/laacz)]
* Add `get_last_statement()` - closes issue #84 [[tag](https://github.com/tag)]
+* Fix when using `set_expr` alone it doesn't trigger query creation - closes issue #90
#### 1.2.3 - release 2012-11-28
diff --git a/idiorm.php b/idiorm.php
index 251b53e..9ca1de1 100644
--- a/idiorm.php
+++ b/idiorm.php
@@ -1329,7 +1329,7 @@
if (!$this->_is_new) { // UPDATE
// If there are no dirty values, do nothing
- if (count($values) == 0) {
+ if (empty($values) && empty($this->_expr_fields)) {
return true;
}
$query = $this->_build_update();
diff --git a/test/test_queries.php b/test/test_queries.php
index d3749cb..d30a49f 100755
--- a/test/test_queries.php
+++ b/test/test_queries.php
@@ -326,6 +326,12 @@
$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);
+ $widget = ORM::for_table('widget')->find_one(1);
+ $widget->set_expr('added', 'NOW()');
+ $widget->save();
+ $expected = "UPDATE `widget` SET `added` = NOW() WHERE `id` = '1'";
+ Tester::check_equal("Issue #90 - When using set_expr alone it doesn't trigger query creation", $expected);
+
// Tests that alter Idiorm's config are done last
ORM::configure('id_column', 'primary_key');