Skip to content
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
Labels
bug A bug report status: medium Medium
Milestone

Comments

@limingxinleo
Copy link
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 mentioned this issue Nov 20, 2017
3 tasks
@sergeyklay sergeyklay added this to the 3.3.x milestone Nov 20, 2017
sergeyklay pushed a commit that referenced this issue Nov 20, 2017
* Add Dynamic Update And RawValue Unit Test

* Fix Bug #Issue 13170
@sergeyklay sergeyklay changed the title DynamicUpdate And RawValue Dynamic update does not work as expected for fields which raw values were assigned to Nov 20, 2017
@sergeyklay
Copy link
Contributor

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.

chilimatic pushed a commit to chilimatic/cphalcon that referenced this issue Jan 15, 2018
* Add Dynamic Update And RawValue Unit Test

* Fix Bug #Issue 13170
@niden niden added bug A bug report status: medium Medium and removed Bug - Medium labels Dec 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug report status: medium Medium
Projects
None yet
Development

No branches or pull requests

3 participants