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

Data not update when update value from integer to decimal #3247

Closed
ohmcoe opened this issue Jan 19, 2015 · 6 comments
Closed

Data not update when update value from integer to decimal #3247

ohmcoe opened this issue Jan 19, 2015 · 6 comments

Comments

@ohmcoe
Copy link

ohmcoe commented Jan 19, 2015

I use phalcon 1.3.4 build from source.
database: mysql
And use models with useDynamicUpdate(true);

Example.
When update model value from 4 to 4.00 (type of field in database is longtext) the value in database is not change.

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@sergeyklay
Copy link
Member

@ohmcoe Can you give an small example of your code please? Also provide table schema.

@ohmcoe
Copy link
Author

ohmcoe commented Jan 20, 2015

Table export from mysql

CREATE TABLE IF NOT EXISTS `test` (
`id` int(10) unsigned NOT NULL,
  `value` longtext NOT NULL
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;

INSERT INTO `test` (`id`, `value`) VALUES
(1, '4');

ALTER TABLE `test`
 ADD PRIMARY KEY (`id`);

This models file.

class Test extends \Phalcon\Mvc\Model
{
    public $id;
    public $value;

    public function initialize()
    {
        $this->useDynamicUpdate(true);
    }
}

this code to change value

      $test = Test::findFirst("id='1'");
      $test->value = '4.00';
      $test->save();

the record in table test id 1 value is not change from 4 to 4.00

@olivier-monaco
Copy link
Contributor

Your problem is here: https://github.com/phalcon/cphalcon/blob/2.0.0/phalcon/mvc/model.zep#L2317

The beauty of low typed language is to be able to compare apple with birds... Try this and you're be suprised !

$a = '4';
$b = '4.0';
var_dump($a, $b, $a == $b, $a === $b);

But the bugfix is not so easy... What about putting an INT column with 4 as value replaced by '4'? No update is required...

@olivier-monaco
Copy link
Contributor

I try do review code of 2.0.0 to better detect changes. But maybe it is too strict now...

@olivier-monaco
Copy link
Contributor

Use the last 2.0.0. This bug is fixed.

@Green-Cat
Copy link
Contributor

@andresgutierrez Fixed in #9996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants