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

#1447. On preInsert object in TimestampableBehavior we get different… #1457

Merged
merged 1 commit into from
Feb 12, 2018
Merged

#1447. On preInsert object in TimestampableBehavior we get different… #1457

merged 1 commit into from
Feb 12, 2018

Conversation

eugenekurasov
Copy link
Contributor

… dataTime.

For solve this situation we need available set same time on create and update field.

/**
* Get a DateTime object with milliseconds resolution.
*
* @param null $time
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the alternative value? should be stated here, too.

@eugenekurasov
Copy link
Contributor Author

Yeah, tests passed

@eugenekurasov
Copy link
Contributor Author

@marcj can you merge this PR?
Fix for #1447

@@ -85,7 +85,7 @@ public function preUpdate($builder)
if ($this->withUpdatedAt()) {
$valueSource = strtoupper($this->getTable()->getColumn($this->getParameter('update_column'))->getType()) === 'INTEGER'
? 'time()'
: '\\Propel\\Runtime\\Util\\PropelDateTime::createHighPrecision()'
: '\\Propel\\Runtime\\Util\\PropelDateTime::createSameHighPrecision(1)'
Copy link
Member

@marcj marcj Feb 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createSameHighPrecision has as first argument a bool, not a integer.

@marcj
Copy link
Member

marcj commented Feb 7, 2018

Can you talk a bit about that solution and why you've chosen to use a static global stored timestamp in the PropelDateTime class? I don't think that is very elegant, maybe you can show me what the actual error is so we can find a more sexy solution.

? 'time()'
: '\\Propel\\Runtime\\Util\\PropelDateTime::createHighPrecision()'
: '\\Propel\\Runtime\\Util\\PropelDateTime::createSameHighPrecision(1)'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@eugenekurasov
Copy link
Contributor Author

eugenekurasov commented Feb 9, 2018

Hi @marcj
I try found is more easy solution for preInsert action.
So I need to have same value for insert database on preInsert.
createHighPrecision - give me different values each time, and this is like object is was modify, but is not true.
So I need HighPrecision with save state for Insert and update. And I think private static is transparent solution and is small evil.

Other solution - is change generated script with additional conditions for check if created date is exist and update exist - generate once time.
But of this solution I need to check what fields type, and if they different I need to convert value. I think it is incomprehensible solution solution.

If you have any idea how I can do it for easy understand and without static - I will be try do it.

I will be change number to boolean.

@eugenekurasov
Copy link
Contributor Author

@marcj I set boolean type instead integer.
For preUpdate method I roll back change.

@eugenekurasov
Copy link
Contributor Author

@marcj I have found solution without using static variable.
Can you check PR again please.

… dataTime.

 For solve this situation we need available set same time on create and update field.
@marcj
Copy link
Member

marcj commented Feb 12, 2018

That looks way better, thanks!

@marcj marcj merged commit 3dde104 into propelorm:master Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants