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

Fix #15994 - Attribute bug when default current_timestamp used with on update current_timestamp #16653

Merged
merged 1 commit into from
Feb 16, 2021

Conversation

iifawzi
Copy link
Contributor

@iifawzi iifawzi commented Feb 15, 2021

Signed-off-by: Fawzi E. Abdulfattah iifawzie@gmail.com

Description

It seems like the bug in #15994 is occurred ONLY in the following case:

  • when the default attribute is set to CURRENT_TIMESTAMP and an on update CURRENT_TIMESTAMP is used, this leads to generate the following Extra field: DEFAULT_GENERATED ON UPDATE CURRENT_TIMESTAMP as shown below (tested on the PMA demo with version 5.2.0-dev)
    Screen Shot 2021-02-15 at 9 18 47 PM

which fails this check:

and column_meta['Extra'] == 'on update CURRENT_TIMESTAMP' %}
{% set attribute = 'on update CURRENT_TIMESTAMP' %}

i've changed it to check if the extra field contains on update CURRENT_TIMESTAMP or not.

Fixes #15994

@codecov
Copy link

codecov bot commented Feb 15, 2021

Codecov Report

Merging #16653 (787a820) into QA_5_1 (88752d6) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             QA_5_1   #16653   +/-   ##
=========================================
  Coverage     53.03%   53.03%           
  Complexity    15168    15168           
=========================================
  Files           470      470           
  Lines         63112    63112           
=========================================
  Hits          33469    33469           
  Misses        29643    29643           
Flag Coverage Δ Complexity Δ
dbase-extension 52.66% <ø> (ø) 0.00 <ø> (ø)
recode-extension 52.62% <ø> (ø) 0.00 <ø> (ø)
unit-7.1-ubuntu-latest 52.62% <ø> (ø) 0.00 <ø> (ø)
unit-7.2-ubuntu-latest 52.80% <ø> (ø) 0.00 <ø> (ø)
unit-7.3-ubuntu-latest 57.61% <ø> (ø) 0.00 <ø> (ø)
unit-7.4-ubuntu-latest 57.62% <ø> (ø) 0.00 <ø> (ø)
unit-8.0-ubuntu-latest 57.78% <ø> (ø) 0.00 <ø> (ø)

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


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 88752d6...9503151. Read the comment docs.

@williamdes williamdes self-assigned this Feb 15, 2021
@williamdes williamdes added this to the 5.1.0 milestone Feb 15, 2021
@williamdes williamdes added this to In progress in pull-requests via automation Feb 15, 2021
@williamdes williamdes moved this from In progress to Review in progress in pull-requests Feb 15, 2021
pull-requests automation moved this from Review in progress to Reviewer approved Feb 15, 2021
Copy link
Member

@williamdes williamdes left a comment

Choose a reason for hiding this comment

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

This looks like a good fix !

@williamdes
Copy link
Member

@sudo-robot deploy

@sudo-robot
Copy link

sudo-robot commented Feb 15, 2021

Deployed (phpmyadmin-pr-16653): fix-extra-attribute-bug commit: c5f7735cce63b454e94b56853953e89e62c66529

url: https://phpmyadmin-pr-16653.wdes.eu.org
user: public
user: public


Deploy finished

@williamdes
Copy link
Member

Hi @iifawzi

I could confirm that your fix works only for MySQL, could you make it MariaDB compatible ?

tested using the deployed server

@iifawzi
Copy link
Contributor Author

iifawzi commented Feb 15, 2021

Hi @iifawzi

I could confirm that your fix works only for MySQL, could you make it MariaDB compatible ?

tested using the deployed server

Hmm, it seems like that's because MariaDB generate the Extra field with additional Parentheses:
ON UPDATE CURRENT_TIMESTAMP()

I will work on it

@iifawzi
Copy link
Contributor Author

iifawzi commented Feb 16, 2021

i've added an or statement to check the case if it was with parentheses, I was thinking about using regex to delete the parentheses from the Extra column, but this would maybe cause an unexpected bugs/errors if there was other parentheses.

@williamdes
Copy link
Member

williamdes commented Feb 16, 2021

i've added an or statement to check the case if it was with parentheses, I was thinking about using regex to delete the parentheses from the Extra column, but this would maybe cause an unexpected bugs/errors if there was other parentheses.

Maybe you could add a starts with or ends with https://twig.symfony.com/doc/3.x/templates.html#comparisons

And add a comment {# MariaDB has additional parentheses #}

What do you think ?
(could you squash your commits and force push ?)

@iifawzi
Copy link
Contributor Author

iifawzi commented Feb 16, 2021

i've added an or statement to check the case if it was with parentheses, I was thinking about using regex to delete the parentheses from the Extra column, but this would maybe cause an unexpected bugs/errors if there was other parentheses.

Maybe you could add a starts with or ends with https://twig.symfony.com/doc/3.x/templates.html#comparisons

And add a comment {# MariaDB has additional parentheses #}

What do you think ?
(could you squash your commits and force push ?)

I think starts with wouldn't work with MySql, since in MySql, the Extra field is generated as following (when default is used): DEFAULT_GENERATED ON UPDATE CURRENT_TIMESTAMP, am i missing something?

sure, i will squash them and add the comment.

@williamdes
Copy link
Member

Indeed, very accurate, I seem to have missed that detail
I will merge your work tomorrow (16/02) after your squash ;)

Signed-off-by: Fawzi E. Abdulfattah <iifawzie@gmail.com>
@iifawzi
Copy link
Contributor Author

iifawzi commented Feb 16, 2021

Indeed, very accurate, I seem to have missed that detail
I will merge your work tomorrow (16/02) after your squash ;)

Awesome, thanks for your time reviewing this.

@williamdes williamdes linked an issue Feb 16, 2021 that may be closed by this pull request
@williamdes williamdes merged commit 9316921 into phpmyadmin:QA_5_1 Feb 16, 2021
pull-requests automation moved this from Reviewer approved to Done Feb 16, 2021
williamdes added a commit that referenced this pull request Feb 16, 2021
It was lowercase on MariaDB 10.4

Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes
Copy link
Member

I added 5e5733d because it did not work on my MariaDB 10.4 instance, using a lowercase compare is safer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
pull-requests
  
Done
Development

Successfully merging this pull request may close these issues.

"Extra" column definition not editable
3 participants