Closed aless673 closed 7 years ago
This sounds like expected behaviour. How would you expect to get the database's record without querying for it? The idiorm object only knows what you've told it until you query the database again.
On 7 Jan 2017 2:23 a.m., "Alessandro GIULIANI" notifications@github.com wrote:
Hi,
I have a lot of default values managed by postgres and after a initial save my object does not get updated with postgres default values. I need to use find_one again to get those default values.
Is there an other way ?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/j4mie/idiorm/issues/313, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD-v6HchxlPm-xODT3Yn_-HlhI_HonQks5rPmqEgaJpZM4Lc3bI .
The idiorm object is updated after the first save only on its id. It could be updated for any fields, or at least the save function could return the db's record. It looks weird to ask the record just after its creation.
Using last insert ID to get the auto increment ID is very different to fetching a record and updating the entire model.
If you really want this behavior then write a wrapper around idiorm that does the insert and then the fetch. I would advise against it however.
A few reasons this would never appear in Idiorm:
On 7 Jan 2017 8:03 a.m., "Alessandro GIULIANI" notifications@github.com wrote:
The idiorm object is updated after the first save only on its id. It could be updated for any fields, or at least the save function could return the db's record. It looks weird to ask the record just after its creation.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/j4mie/idiorm/issues/313#issuecomment-271021418, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD-v0X8rXcB9ZpZhHtO0gbdXz77K4RAks5rPrpHgaJpZM4Lc3bI .
There could be a function to update the record (maybe $obj->fetch()). It would be less disturbing when reading the code.
If you really like the idea then write a wrapper - this will not be going into idiorm because it doesn't meet the principles of simplicity that idiorm was set out on and there is also a feature freezer in place and only maintenance patches are accepted.
On 7 Jan 2017 10:35 a.m., "Alessandro GIULIANI" notifications@github.com wrote:
There could be a function to update the record (maybe $obj->fetch()). It would be less disturbing when reading the code.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/j4mie/idiorm/issues/313#issuecomment-271046976, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD-v-cdhMJbed1L-HqW5J9GAzuh6Sz1ks5rPt3jgaJpZM4Lc3bI .
Hi,
I have a lot of default values managed by postgres and after a initial save my object does not get updated with postgres default values. I need to use find_one again to get those default values.
Is there an other way ?