-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Problem with UPDATE on DATE primary key #676
Comments
The problem shows up when the actual column type is |
I'd say the proper fix is $id = $entity->getPersistedId();
if (!is_array($id)) {
$id = [$id];
} that was AFAIR the intention. PR welcomed :) |
So I managed to fix the tests
|
@hrach is there any chance to get it into the 4.0 branch and release? |
Any chance you would rather consider updating to 5.0@dev? I tested it on my big project though haven't enough time to release it finally. |
I can suggest it, as I see no BC breaks. But we have a few projects with a common core which are running in production but with continuous new development and updating major version of libraries takes time (and ORM is quite an entrenched one). |
Make sense. I can take a look at how feasible backporting is. |
# Conflicts: # tests/cases/integration/Entity/entity.compositePK.phpt # tests/db/mssql-init.sql # tests/db/mysql-init.sql # tests/db/pgsql-init.sql # tests/sqls/NextrasTests/Orm/Integration/Entity/EntityPkTest_testDateTimeWithProxyPk.sql
@jkavalik Ok, I tried backporting this but there is a serious problem: The This was fixed in Nextras Orm 5 in this commit: But to apply this on Nextras Orm 4, I would have to do much more serious refactoring/cherry-picking, because the ExpressionResult does not contain there the dbalModifier property, etc. Simply said, that does not make sense and would be problematic for 4.0 to change behavior. CI failure can be seen here: Removing the commit from 4.0 branch. |
@hrach thanks for trying :) But it is weird because I tried it already locally in my project (mysql/mariadb, orm 4.0.7) and it worked fine for my use case at least :) Gotta check what is different in the test.. |
I see, it works for me because of |
and I can make the tests work by setting tefault TZ to UTC in bootstrap, which makes other tests fail ofc :) I made the tests work by using the same timezone in the datetime objects as in the db but I was not able to access the actual I understand though that that's not a solution because it is quite cumbersome in the case the db and php timezones differ. |
The core of this is a "mega" issue that Orm pre-5.0 was not using a modifier. Therefore there was autodetection of DateTime type and DATE columns were always malformed. :( IMO it doesn't make sense to put it to 4.0 officially, if you are able to keep a fork/PR that you can use for your composer, good :) |
I agree, thank you for your time :) |
Hello @hrach , today I stumbled onto another instance of the problem we already discussed in #320 when using
Seems that
\Nextras\Orm\Mapper\Dbal\DbalMapper::persist()
was not fixed and it still containswhich converts the Datetime instance into 3-item array and then tries to use the first part (string) as the PK and fails with
Modifier %?dts expects value to be DateTime, string given.
again.I was able to fix it locally with
I can prepare a pull request with that change in persist(), processMySQLAutoupdate() and remove() if it helps.
The text was updated successfully, but these errors were encountered: