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 #9318 change postgres driver version checking query #9319

Merged
merged 5 commits into from
Aug 25, 2022
Merged

fix #9318 change postgres driver version checking query #9319

merged 5 commits into from
Aug 25, 2022

Conversation

CaptainCrucial
Copy link
Contributor

@CaptainCrucial CaptainCrucial commented Aug 24, 2022

Description of change

Change Postgres driver version checking query to add compatibility with the Postgres compatible AWS Redshift database.

When connecting using the Postgres driver, the afterConnect method is running the SQL SHOW server_version; as part of feature support detection. This command works on postgres and cockroachdb, but is incompatible with the postgres compatible redshift database.

This change adjusts the postgres SHOW server_version query to use SELECT version() which is supported by Postgres and CockroachDB, and gives compatibility with AWS Redshift database

Example command outputs:

Redshift
SELECT version();
PostgreSQL 8.0.2 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3), Redshift 1.0.40677

Postgresql
SELECT version();
PostgreSQL 14.5 (Debian 14.5-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
PostgreSQL 11.16 (Debian 11.16-1.pgdg90+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 64-bit

SHOW server_version;
14.5 (Debian 14.5-1.pgdg110+1)
11.16 (Debian 11.16-1.pgdg90+1)

Fixes #9318

Pull-Request Checklist

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

CaptainCrucial and others added 5 commits August 24, 2022 15:07
fix: change postgres driver version checking query

Change the postgres `SHOW server_version` query to use `SELECT version()` which adds compatibility with AWS Redshift database

Closes: #9318
@pleerock pleerock merged commit c4f4650 into typeorm:master Aug 25, 2022
@pleerock
Copy link
Member

Thank you for contribution! 🎉

@CaptainCrucial CaptainCrucial deleted the fix-9318 branch August 25, 2022 13:56
nordinh pushed a commit to nordinh/typeorm that referenced this pull request Aug 29, 2022
* fix typeorm#9318

fix: change postgres driver version checking query

Change the postgres `SHOW server_version` query to use `SELECT version()` which adds compatibility with AWS Redshift database

Closes: typeorm#9318

* git-issue 9318: remove describe from only in test

* fix-9318: prettier format test
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.

Postgres version command incompatible with Redshift
2 participants