Assuming you have a model conforming to Timestampable you would expect that its createdAt and updatedAt values are updated properly. This works fine when using Fluent's save() method. It does not, when using create(orUpdate:on:).
Observed behavior
(given that createdAt/updatedAt are not set manually before upserting the model)
first creation works as expected (createdAt/updatedAt are set properly, as this is handled by Fluent's QueryBuilder create(_ model: Result))
any subsequent updates using create(orUpdate:on:) will result into createdAt/updatedAt being reset to NULL
Expected behavior
When upserting ...
... the value for createdAt should not change
... the value for updatedAt should be updated to current Date()
Assuming you have a model conforming to
Timestampable
you would expect that itscreatedAt
andupdatedAt
values are updated properly. This works fine when using Fluent'ssave()
method. It does not, when usingcreate(orUpdate:on:)
.Observed behavior
(given that
createdAt
/updatedAt
are not set manually before upserting the model)createdAt
/updatedAt
are set properly, as this is handled by Fluent's QueryBuildercreate(_ model: Result)
)create(orUpdate:on:)
will result intocreatedAt
/updatedAt
being reset to NULLExpected behavior
When upserting ...
createdAt
should not changeupdatedAt
should be updated to currentDate()
Affects
Fluent 3 (3.1.0)