-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: change postgres driver version checking query (#9319)
* fix #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: #9318 * git-issue 9318: remove describe from only in test * fix-9318: prettier format test
- Loading branch information
1 parent
3671887
commit c4f4650
Showing
4 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import "reflect-metadata" | ||
import { | ||
createTestingConnections, | ||
closeTestingConnections, | ||
reloadTestingDatabases, | ||
} from "../../utils/test-utils" | ||
import { DataSource } from "../../../src" | ||
|
||
import { expect } from "chai" | ||
import { PostgresDriver } from "../../../src/driver/postgres/PostgresDriver" | ||
import { VersionUtils } from "../../../src/util/VersionUtils" | ||
|
||
describe("github issues > #9318 Change version query from SHOW server_version to SELECT version", () => { | ||
let connections: DataSource[] | ||
before( | ||
async () => | ||
(connections = await createTestingConnections({ | ||
entities: [], | ||
schemaCreate: false, | ||
dropSchema: true, | ||
enabledDrivers: ["postgres"], | ||
})), | ||
) | ||
beforeEach(() => reloadTestingDatabases(connections)) | ||
after(() => closeTestingConnections(connections)) | ||
|
||
it("should have proper isGeneratedColumnsSupported value for postgres version", () => | ||
Promise.all( | ||
connections.map(async (connection) => { | ||
const { isGeneratedColumnsSupported } = | ||
connection.driver as PostgresDriver | ||
const result = await connection.query("SELECT VERSION()") | ||
const dbVersion = result[0]["version"].replace( | ||
/^PostgreSQL ([\d\.]+) .*$/, | ||
"$1", | ||
) | ||
const versionGreaterOfEqualTo12 = VersionUtils.isGreaterOrEqual( | ||
dbVersion, | ||
"12.0", | ||
) | ||
|
||
expect(isGeneratedColumnsSupported).to.eq( | ||
versionGreaterOfEqualTo12, | ||
) | ||
}), | ||
)) | ||
}) |