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
Transaction with custom sql exec not updating results #1091
Comments
tried turning instance pooling off? |
Just tried with this: I made a custom accesor getXXXJSON($con) and it succesfully see those changes using |
My bet was also on instance pooling. Maybe activate query logging on mysql ( Or, since the title speaks of transactions, another idea is if your custom mysql function hasn't yet committed the changes in a way that the connection session of the reload sees them. |
@DavidGoodwin @mentalstring Propel::disableInstancePooling(); Thank you very much. P.D. Do you know a way to handle DML senteces with JSON capabilities through PropelORM? |
No; sorry; beyond my pay grade ;-) (not something I've had to think about / use) |
Context:
I'm using JSON fields on MySQL 8 though a custom function that allows me to handle all changes on MySQL instead of retrieving whole object to PHP, modify it and store it again, that must be the basic approach of propelorm on this data type.
I've created a custom setXXX method that takes the data to be modified and a Connection Interface as parameters to acomplish this but things gets weird at this point.
I'm testing the use cases for this with PHPUnit doing the following:
$obj = new \TableName();
$obj->setXXX('{}'): // Using setter method provided by PropelORM
$obj->save($con);
Modify JSON field with custom method
$obj->setXXXJSON('{"action":"set", "prop":"val"}', $con);
Save method is not used because there's any change to the proper object but it needs to be refreshed to get the new JSON Field Value
$obj = TableNameQuery::create()->findOneById($obj->getId());
Issue:
This means that 2. Modify JSON field with custom method actually happend but i cannot get that value back even though its stored at the database and instead I get the previous unmodified version of it
I've tried to create a new object
$other = \TableNameQuery::create()->findOneById($obj->getId());
But it shows the same field without been affected
$other->getXXX():
Expected: {"prop":"val"}
Actual: "{}"
While writing this I realized that I can change this from fuction to procedure to be executed internally by MySQL without the need to return the statement string to PHP to do that.
Also I'll try to create a new accesor method using custom sql to get this particular field to see if I'm able to see the change.
Thanks!
The text was updated successfully, but these errors were encountered: