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

Support ON UPDATE CURRENT_TIMESTAMP in MySQL #1967

Merged
merged 5 commits into from
Dec 7, 2023

Conversation

Mau04
Copy link
Contributor

@Mau04 Mau04 commented May 23, 2023

This PR adds support for defaultExpr="CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP" for MySQL as requested in #1203. Previously, a migration would always contain an ALTER Statement to set ON UPDATE CURRENT_TIMESTAMP although it is already like that in the database. The root cause was that the Extra part was not checked in the MysqlSchemaParser class.

@codecov-commenter
Copy link

codecov-commenter commented May 23, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (4f36eea) 89.27% compared to head (9ddf3c9) 89.27%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1967   +/-   ##
=========================================
  Coverage     89.27%   89.27%           
- Complexity     8049     8053    +4     
=========================================
  Files           232      232           
  Lines         24519    24526    +7     
=========================================
+ Hits          21889    21896    +7     
  Misses         2630     2630           
Flag Coverage Δ
5-max 89.27% <100.00%> (+<0.01%) ⬆️
7.4 89.27% <100.00%> (+<0.01%) ⬆️
agnostic 67.46% <50.00%> (-0.01%) ⬇️
mysql 69.79% <37.50%> (-0.02%) ⬇️
pgsql 69.83% <75.00%> (+<0.01%) ⬆️
sqlite 67.78% <12.50%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/Propel/Generator/Platform/PgsqlPlatform.php 97.84% <100.00%> (+0.02%) ⬆️
src/Propel/Generator/Platform/SqlitePlatform.php 92.96% <100.00%> (ø)
src/Propel/Generator/Reverse/MysqlSchemaParser.php 88.84% <100.00%> (+0.09%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Mau04 Mau04 marked this pull request as draft May 23, 2023 06:48
@Mau04 Mau04 marked this pull request as ready for review May 23, 2023 07:52
Copy link
Contributor

@mringler mringler left a comment

Choose a reason for hiding this comment

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

Nice! Small question, the rest looks good!

@@ -264,6 +264,8 @@ public function getColumnFromRow(array $row, Table $table): Column
// BLOBs can't have any default values in MySQL
$default = preg_match('~blob|text~', $nativeType) ? null : $row['Default'];

$extra = $row['Extra'];
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain why this is necessary here? When I look at the code, it does not look like $row is changed between here and line 300, where you use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea was to take it out of the row just once in case it is used multiple times so that there is only one index access for Extra. But it turned out to be used only once, so I could move it to line 300 as well. However, it might be easier to read the way it is now. Please let me know what you prefer and I'll adjust it accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. Personally, I'd prefer it in line 300, as there is no benefit to moving it further up at the moment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me. I changed it accordingly.

@mringler
Copy link
Contributor

@Mau04 It looks like the old maintainer of Propel2, @dereuromark, has left the project, and it looks like there is no successor at Spryker at the moment. I have contacted the owner, and he told me that the project will keep being maintained by Spryker, but I haven't heard back if/when there will be someone who actively maintains Propel2, i.e. merges this PRs.
For what it's worth, I am very sorry for the situation! This should have been merged month ago, with all the thanks and commendations that are in order. I found getting acquainted with Propel and creating a PR takes effort, and I wish your first contribution to the project had been a more rewarding experience.
I guess when/if someone takes over, contributors like you and I can decide if they want to come back.
Best wishes

@a-sabaa
Copy link

a-sabaa commented Sep 1, 2023

Hello @mringler & @Mau04
Community contributions are the backbone of Propel, and Spryker aims to play a supportive role in enhancing this ecosystem. We're actively looking for core contributors while improving our own support levels. Expect quicker, more impactful responses to PRs and contributions going forward, as we are ramping up the developer effort on the open PRs in the repository.

Thank you for your vital role in this community.
We're excited for more collaborative achievements

Copy link
Contributor

@olhalivitchuk olhalivitchuk left a comment

Choose a reason for hiding this comment

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

Hi @Mau04!
Thanks for contributing!
Would be great to make CI green and the PR will be merged afterwards.
No other objections from our side.

@gechetspr gechetspr merged commit 6558606 into propelorm:master Dec 7, 2023
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.

6 participants