josegonzalez / cakephp-version

CakePHP3: plugin that facilitates versioned database entities
MIT License
51 stars 22 forks source link

failed test for null datetime field #48

Open matteorebeschi opened 2 years ago

matteorebeschi commented 2 years ago

This is the failing test for the datetime field as discussed in #47

jeremyharris commented 2 years ago

Great, thanks! Test looks good. Now that we have a test, if you like you can put your first fix in here. I've got some ideas on how to address it and improve the code you posted, if you don't mind me tweaking it.

matteorebeschi commented 2 years ago

I've tried changing the convertFieldsToType to what I mentioned in the error thread, but the tests keep failing, so I'm not even sure that that's a good starting point anymore. But feel free to go ahead and tweak it if you have any ideas!

jeremyharris commented 2 years ago

Hey @matteorebeschi, I was able to look at this. I looked at your tests and I think you had the fixture set up incorrectly.

I reworked the fixture and added tests for both null support and DateTime. The tests still pass, so it can successfully version null values and DateTimes. It never serializes the data in the way the original issues shows.

So far I can't replicate the problem

  1. Are you able to tweak testDateTimeSupport or copy/paste it and recreate your scenario, that is, saving some datetime/null data and it failing to return from ->version()?
  2. Are you using a custom database Type for your datetimes?