New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic update does not work as expected for fields which raw values were assigned to #13170

Closed
limingxinleo opened this Issue Nov 20, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@limingxinleo
Contributor

limingxinleo commented Nov 20, 2017

DynamicUpdate And RawValue

When I set useDynamicUpdate=true, and the origin value = 1, then I set
model->value = \Phalcon\Db\RawValue('value + 1').
When I save, The value is not changed.

When I change value type is bigint, the result is right.
When the value type is int, the result is wrong.

<?php
class TDksRouteRequestLog extend \Phalcon\Mvc\Model {
    public function initialize()
    {
        $this->useDynamicUpdate(true);
    }
}

$hour = date('YmdH');
$route = '/api/log';

$model = TDksRouteRequestLog::findFirst([
    'conditions' => 'hour = ?0 AND route = ?1',
    'bind' => [$hour, $route],
]);

if (empty($model)) {
    $model = new TDksRouteRequestLog();
    $model->hour = $hour;
    $model->route = $route;
    $model->request = 1;
} else {
    $model->request = new RawValue('request + 1');
}

$model->save();

SQL: UPDATE `dks`.`t_dks_route_request_log` SET `gmt_modify` = ? WHERE `id` = ?
BINDS: ["2017-11-20 11:55:19",12]

Details

  • Phalcon version: (3.2.4)
  • PHP Version: (7.0.25)
  • Operating System:
  • Installation type:installing via package manager
  • Zephir version (if any):
  • Server: Nginx
  • Other related info (Database, table schema):

@limingxinleo limingxinleo referenced this issue Nov 20, 2017

Merged

Bug Fix #13170 #13171

3 of 3 tasks complete

@sergeyklay sergeyklay added this to the 3.3.x milestone Nov 20, 2017

sergeyklay added a commit that referenced this issue Nov 20, 2017

Bug Fix #13170 (#13171)
* Add Dynamic Update And RawValue Unit Test

* Fix Bug #Issue 13170

@sergeyklay sergeyklay changed the title from DynamicUpdate And RawValue to Dynamic update does not work as expected for fields which raw values were assigned to Nov 20, 2017

@sergeyklay

This comment has been minimized.

Show comment
Hide comment
@sergeyklay

sergeyklay Nov 20, 2017

Member

Fixed in the 3.3.x branch. Feel free to open a new issue if the problem appears again. Thank you for the report, and for helping us make Phalcon better.

Member

sergeyklay commented Nov 20, 2017

Fixed in the 3.3.x branch. Feel free to open a new issue if the problem appears again. Thank you for the report, and for helping us make Phalcon better.

@sergeyklay sergeyklay closed this Nov 20, 2017

chilimatic added a commit to chilimatic/cphalcon that referenced this issue Jan 15, 2018

Bug Fix phalcon#13170 (phalcon#13171)
* Add Dynamic Update And RawValue Unit Test

* Fix Bug #Issue 13170
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment