Skip to content
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

[RFC] Require Timestampable model behavior only take one field #165

Open
SidRoberts opened this issue May 3, 2019 · 4 comments
Open

[RFC] Require Timestampable model behavior only take one field #165

SidRoberts opened this issue May 3, 2019 · 4 comments

Comments

@SidRoberts
Copy link

Something that I found in phalcon/cphalcon#14027 is that the Timestampable model behavior has the option to pass a string or an array of fields:

https://github.com/phalcon/cphalcon/blob/7d8ffd16f6f44bf28d0d700b34cfd6121494023a/phalcon/Mvc/Model/Behavior/Timestampable.zep#L80

If you pass an array, those fields will be updated with the same timestamp and in the same format:

+-----+---------------------+---------------------+
| ID  | Timestamp1          | Timestamp2          |
|-----|---------------------|---------------------|
| 123 | 2019-05-04 08:55:23 | 2019-05-04 08:55:23 |
+-----+---------------------+---------------------+

Why would anyone need to legitimately use this? Is it safe to remove passing as an array?

@SidRoberts SidRoberts changed the title [RFC] Require \Timestampable model behavior only take one field [RFC] Require Timestampable model behavior only take one field May 4, 2019
@sergeyklay
Copy link

I could be wrong, but it seems @Jurigag can help us here.

@JABirchall
Copy link

JABirchall commented May 4, 2019

Allows to automatically update a model’s attribute saving the datetime when a record is created or updated

So it should function the same as laravels timestamp attributes where created_at is set when the record is added and updated_at is changed when the record is updated. But it looks like all the datetime fields are updated to same time no matter what.

@SidRoberts
Copy link
Author

Yeah, I think on creation, only createdAt should be altered. Technically, it hasn't been updated so updatedAt shouldn't have a value.

@niden
Copy link
Member

niden commented May 18, 2019

I am fine with this being changed to only one field per model.

@niden niden transferred this issue from phalcon/cphalcon Oct 1, 2021
@stale stale bot added the stale Stale issue scheduled to be deleted label Apr 20, 2022
@phalcon phalcon deleted a comment from stale bot Apr 20, 2022
@stale stale bot removed the stale Stale issue scheduled to be deleted label Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

4 participants