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

Model castOnHydrate and useDynamicUpdate can't be used simultaneously #12147

Closed
pfz opened this issue Aug 16, 2016 · 6 comments
Closed

Model castOnHydrate and useDynamicUpdate can't be used simultaneously #12147

pfz opened this issue Aug 16, 2016 · 6 comments
Labels
bug A bug report status: medium Medium
Milestone

Comments

@pfz
Copy link
Contributor

pfz commented Aug 16, 2016

My purpose is to get a configuration for a coherent type cast/bind in the ORM, while being able to use snapshots in models (and dynamic update). For instance, I have less (none) rounding problems when mysql driver delivers a float instead of a string php has to parse very carefully.

But neither PDO::ATTR_EMULATE_PREPARES to false, nor castOnHydrate work is this configuration (models using BIT column).
3rd bug is therefore the most annoying to me. 2nd was supposed to be temporary workaround, that doesn't work either... I assume ATTR_EMULATE_PREPARES is better than castOnHydrate, though i may be wrong about it.

I wrote a script to test easily all those points : phalcon_orm_datatype_bug.php
Hope it will help...

This script provides a test for #11205 as well.

Bugs

  1. Whatever the settings, on Model::save(), *->id (last_insert_id) is always a string, should be cast. Not really phalcon's fault here, more a PDO bug I assume. Would be great though.
  2. can't use BIT(1) column if PDO::ATTR_EMULATE_PREPARES=false. Inserts and updates are not processed.
  3. castOnHydrateand useDynamicUpdatecan't be used(true) simultaneously.
    Model::findFirst() triggers this error :
PHP Fatal error:  Uncaught Phalcon\Mvc\Model\Exception:
Column 'id' doesn't make part of the column map

Configuration

  • Phalcon 3.0.x-2d24c0e (tried also with 3.0.0) (tried also with and without xdebug)
  • Zephir 0.9.3a-dev-e716dbe641 (tried also with 0.9.4a-dev-121e9b4bf1)
  • PHP 7.0.9-1~dotdeb+8.1 (cli) ( NTS )
  • MariaDB 10.1.16
@pfz
Copy link
Contributor Author

pfz commented Aug 26, 2016

Tried with 3.0.1 , no success. Is there any best practice around there ? I'm using === in my JS apis and would like the json results to be properly typed/casted. It's a nightmare since it's broken (>2.0).

@BesedinSasha
Copy link
Contributor

I have the same problem.

@sergeyklay
Copy link
Contributor

sergeyklay commented Aug 30, 2016

@pfz @Besedin86
Could you please check 3.0.x branch?

git clone [email protected]:phalcon/cphalcon.git
cd cphalcon
git checkout 3.0.x

 # Use latest Zephir here, from master branch 
zephir fullclean 
zephir build

@BesedinSasha
Copy link
Contributor

BesedinSasha commented Aug 30, 2016

@sergeyklay all is fine.
Test configuration:

  • Ubuntu 16.04
  • MariaDB 10.1.16
  • PHP 7.0.8
  • Phalcon 3.0.1
  • Zephir 0.9.4a-dev-cbfe80715d

@pfz
Copy link
Contributor Author

pfz commented Aug 31, 2016

@sergeyklay issue solved for castOnHydrate with same phalcon/zephir build as Basedin86.

Though PDO::ATTR_EMULATE_PREPARES to false with BIT column still fails. May be I should open an other thread to be consistent on that matter ?

@sergeyklay
Copy link
Contributor

@pfz Yes, open please new issue

@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

4 participants