Skip to content

fix: datetime functions in column "default" leads to unnecessary queries during synchronization#7517

Merged
AlexMesser merged 13 commits intomasterfrom
unnecessary-queries-fix
Apr 1, 2021
Merged

fix: datetime functions in column "default" leads to unnecessary queries during synchronization#7517
AlexMesser merged 13 commits intomasterfrom
unnecessary-queries-fix

Conversation

@AlexMesser
Copy link
Collaborator

@AlexMesser AlexMesser commented Mar 30, 2021

Description of change

Some databases transforms date functions to their aliases when the function used in column default, e.g. CURRENT_TIMESTAMP stored as now() in PostgreSQL. This PR adds mapping for these functions to fix synchronization problems.

  • PostgreSQL:
    • CURRENT_TIMESTAMP -> now()
    • CURRENT_TIMESTAMP(precision) -> ('now'::text)::timestamp(precision) with time zone
    • CURRENT_DATE -> ('now'::text)::date
    • CURRENT_TIME -> ('now'::text)::time with time zone
    • CURRENT_TIME(precision) -> ('now'::text)::time(precision) with time zone
    • LOCALTIME -> ('now'::text)::time without time zone
    • LOCALTIME(precision) -> ('now'::text)::time(precision) without time zone
    • LOCALTIMESTAMP -> ('now'::text)::timestamp without time zone
    • LOCALTIMESTAMP(precision) -> ('now'::text)::timestamp(precision) without time zone
  • SQLServer:
    • CURRENT_TIMESTAMP -> getdate()
  • CockroachDB
    • CURRENT_TIMESTAMP -> current_timestamp()
    • CURRENT_DATE -> current_date()
  • MySQL:
    • CURRENT_TIMESTAMP() -> CURRENT_TIMESTAMP
  • MariaDB:
    • CURRENT_TIMESTAMP -> CURRENT_TIMESTAMP()

fixed issues:

Fixes #2136
Fixes #2718
Fixes #2737
Fixes #3561
Fixes #3991
Fixes #6412
Fixes #6579
Fixes #7381

covered pull-requests:

Closes #7229

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run test passes with this change
  • npm run lint passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • N/A Documentation has been updated to reflect this change
  • The new commits follow conventions explained in CONTRIBUTING.md

@AlexMesser AlexMesser changed the title [WIP] fixing unnecessary queries during schema synchronization fix: Datetime functions in default leads to unnecessary queries during synchronization Mar 31, 2021
@AlexMesser AlexMesser changed the title fix: Datetime functions in default leads to unnecessary queries during synchronization fix: datetime functions in column "default" leads to unnecessary queries during synchronization Mar 31, 2021
@AlexMesser AlexMesser merged commit 03f3285 into master Apr 1, 2021
@AlexMesser AlexMesser deleted the unnecessary-queries-fix branch April 1, 2021 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment