mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
PostgreSQL 10 reports its version as only `major.minor`, so it can’t be parsed with semver. The `server_version_num` setting is a major version followed by a four-digit minor version since version 10, and was a three-digit major version followed by a two-digit minor version before that.
27 lines
678 B
JavaScript
27 lines
678 B
JavaScript
'use strict'
|
|
var helper = require('./../test-helper')
|
|
|
|
if (helper.args.native) {
|
|
Client = require('./../../lib/native')
|
|
helper.Client = Client
|
|
helper.pg = helper.pg.native
|
|
}
|
|
|
|
// creates a client from cli parameters
|
|
helper.client = function (cb) {
|
|
var client = new Client()
|
|
client.connect(cb)
|
|
return client
|
|
}
|
|
|
|
helper.versionGTE = function (client, testVersion, callback) {
|
|
client.query('SHOW server_version_num', assert.calls(function (err, result) {
|
|
if (err) return callback(err)
|
|
var version = parseInt(result.rows[0].server_version_num, 10)
|
|
return callback(null, version >= testVersion)
|
|
}))
|
|
}
|
|
|
|
// export parent helper stuffs
|
|
module.exports = helper
|