diff --git a/packages/gaussdb-cursor/test/close.js b/packages/gaussdb-cursor/test/close.js index 8da5d21cb..2df7ce94d 100644 --- a/packages/gaussdb-cursor/test/close.js +++ b/packages/gaussdb-cursor/test/close.js @@ -1,11 +1,11 @@ const assert = require('assert') const Cursor = require('../') -const pg = require('gaussdb') +const gaussdb = require('gaussdb') const text = 'SELECT generate_series as num FROM generate_series(0, 50)' describe('close', function () { beforeEach(function (done) { - const client = (this.client = new pg.Client()) + const client = (this.client = new gaussdb.Client()) client.connect(done) }) diff --git a/packages/gaussdb-cursor/test/error-handling.js b/packages/gaussdb-cursor/test/error-handling.js index 2bfde2e78..c7b6a7736 100644 --- a/packages/gaussdb-cursor/test/error-handling.js +++ b/packages/gaussdb-cursor/test/error-handling.js @@ -1,13 +1,13 @@ 'use strict' const assert = require('assert') const Cursor = require('../') -const pg = require('gaussdb') +const gaussdb = require('gaussdb') const text = 'SELECT generate_series as num FROM generate_series(0, 4)' describe('error handling', function () { it('can continue after error', function (done) { - const client = new pg.Client() + const client = new gaussdb.Client() client.connect() const cursor = client.query(new Cursor('asdfdffsdf')) cursor.read(1, function (err) { @@ -21,7 +21,7 @@ describe('error handling', function () { }) it('errors queued reads', async () => { - const client = new pg.Client() + const client = new gaussdb.Client() await client.connect() const cursor = client.query(new Cursor('asdfdffsdf')) @@ -55,7 +55,7 @@ describe('error handling', function () { describe('read callback does not fire sync', () => { it('does not fire error callback sync', (done) => { - const client = new pg.Client() + const client = new gaussdb.Client() client.connect() const cursor = client.query(new Cursor('asdfdffsdf')) let after = false @@ -75,7 +75,7 @@ describe('read callback does not fire sync', () => { }) it('does not fire result sync after finished', (done) => { - const client = new pg.Client() + const client = new gaussdb.Client() client.connect() const cursor = client.query(new Cursor('SELECT NOW()')) let after = false @@ -100,7 +100,7 @@ describe('read callback does not fire sync', () => { describe('proper cleanup', function () { it('can issue multiple cursors on one client', function (done) { - const client = new pg.Client() + const client = new gaussdb.Client() client.connect() const cursor1 = client.query(new Cursor(text)) cursor1.read(8, function (err, rows) { diff --git a/packages/gaussdb-cursor/test/index.js b/packages/gaussdb-cursor/test/index.js index 120a935a6..0cacbfd4c 100644 --- a/packages/gaussdb-cursor/test/index.js +++ b/packages/gaussdb-cursor/test/index.js @@ -1,15 +1,15 @@ const assert = require('assert') const Cursor = require('../') -const pg = require('gaussdb') +const gaussdb = require('gaussdb') const text = 'SELECT generate_series as num FROM generate_series(0, 5)' describe('cursor', function () { beforeEach(function (done) { - const client = (this.client = new pg.Client()) + const client = (this.client = new gaussdb.Client()) client.connect(done) - this.pgCursor = function (text, values) { + this.gaussdbCursor = function (text, values) { return client.query(new Cursor(text, values || [])) } }) @@ -19,7 +19,7 @@ describe('cursor', function () { }) it('fetch 6 when asking for 10', function (done) { - const cursor = this.pgCursor(text) + const cursor = this.gaussdbCursor(text) cursor.read(10, function (err, res) { assert.ifError(err) assert.strictEqual(res.length, 6) @@ -28,7 +28,7 @@ describe('cursor', function () { }) it('end before reading to end', function (done) { - const cursor = this.pgCursor(text) + const cursor = this.gaussdbCursor(text) cursor.read(3, function (err, res) { assert.ifError(err) assert.strictEqual(res.length, 3) @@ -37,7 +37,7 @@ describe('cursor', function () { }) it('callback with error', function (done) { - const cursor = this.pgCursor('select asdfasdf') + const cursor = this.gaussdbCursor('select asdfasdf') cursor.read(1, function (err) { assert(err) done() @@ -45,7 +45,7 @@ describe('cursor', function () { }) it('read a partial chunk of data', function (done) { - const cursor = this.pgCursor(text) + const cursor = this.gaussdbCursor(text) cursor.read(2, function (err, res) { assert.ifError(err) assert.strictEqual(res.length, 2) @@ -67,7 +67,7 @@ describe('cursor', function () { }) it('read return length 0 past the end', function (done) { - const cursor = this.pgCursor(text) + const cursor = this.gaussdbCursor(text) cursor.read(2, function (err) { assert(!err) cursor.read(100, function (err, res) { @@ -86,7 +86,7 @@ describe('cursor', function () { this.timeout(10000) const text = 'SELECT generate_series as num FROM generate_series(0, 100000)' const values = [] - const cursor = this.pgCursor(text, values) + const cursor = this.gaussdbCursor(text, values) let count = 0 const read = function () { cursor.read(100, function (err, rows) { @@ -108,7 +108,7 @@ describe('cursor', function () { it('normalizes parameter values', function (done) { const text = 'SELECT $1::json me' const values = [{ name: 'brian' }] - const cursor = this.pgCursor(text, values) + const cursor = this.gaussdbCursor(text, values) cursor.read(1, function (err, rows) { if (err) return done(err) assert.strictEqual(rows[0].me.name, 'brian') @@ -121,7 +121,7 @@ describe('cursor', function () { }) it('returns result along with rows', function (done) { - const cursor = this.pgCursor(text) + const cursor = this.gaussdbCursor(text) cursor.read(1, function (err, rows, result) { assert.ifError(err) assert.strictEqual(rows.length, 1) @@ -135,7 +135,7 @@ describe('cursor', function () { }) it('emits row events', function (done) { - const cursor = this.pgCursor(text) + const cursor = this.gaussdbCursor(text) cursor.read(10) cursor.on('row', (row, result) => result.addRow(row)) cursor.on('end', (result) => { @@ -145,7 +145,7 @@ describe('cursor', function () { }) it('emits row events when cursor is closed manually', function (done) { - const cursor = this.pgCursor(text) + const cursor = this.gaussdbCursor(text) cursor.on('row', (row, result) => result.addRow(row)) cursor.on('end', (result) => { assert.strictEqual(result.rows.length, 3) @@ -156,7 +156,7 @@ describe('cursor', function () { }) it('emits error events', function (done) { - const cursor = this.pgCursor('select asdfasdf') + const cursor = this.gaussdbCursor('select asdfasdf') cursor.on('error', function (err) { assert(err) done() @@ -164,11 +164,11 @@ describe('cursor', function () { }) it('returns rowCount on insert', function (done) { - const pgCursor = this.pgCursor + const gaussdbCursor = this.gaussdbCursor this.client - .query('CREATE TEMPORARY TABLE pg_cursor_test (foo VARCHAR(1), bar VARCHAR(1))') + .query('CREATE TEMPORARY TABLE gaussdb_cursor_test (foo VARCHAR(1), bar VARCHAR(1))') .then(function () { - const cursor = pgCursor('insert into pg_cursor_test values($1, $2)', ['a', 'b']) + const cursor = gaussdbCursor('insert into gaussdb_cursor_test values($1, $2)', ['a', 'b']) cursor.read(1, function (err, rows, result) { assert.ifError(err) assert.strictEqual(rows.length, 0) diff --git a/packages/gaussdb-cursor/test/no-data-handling.js b/packages/gaussdb-cursor/test/no-data-handling.js index abc62b31f..9e0c93035 100644 --- a/packages/gaussdb-cursor/test/no-data-handling.js +++ b/packages/gaussdb-cursor/test/no-data-handling.js @@ -1,10 +1,10 @@ const assert = require('assert') -const pg = require('gaussdb') +const gaussdb = require('gaussdb') const Cursor = require('../') describe('queries with no data', function () { beforeEach(function (done) { - const client = (this.client = new pg.Client()) + const client = (this.client = new gaussdb.Client()) client.connect(done) }) diff --git a/packages/gaussdb-cursor/test/pool.js b/packages/gaussdb-cursor/test/pool.js index fd70ea955..77e04ad0f 100644 --- a/packages/gaussdb-cursor/test/pool.js +++ b/packages/gaussdb-cursor/test/pool.js @@ -1,7 +1,7 @@ 'use strict' const assert = require('assert') const Cursor = require('../') -const pg = require('gaussdb') +const gaussdb = require('gaussdb') const text = 'SELECT generate_series as num FROM generate_series(0, 50)' @@ -33,7 +33,7 @@ function poolQueryPromise(pool, readRowCount) { describe('pool', function () { beforeEach(function () { - this.pool = new pg.Pool({ max: 1 }) + this.pool = new gaussdb.Pool({ max: 1 }) }) afterEach(function () { @@ -85,7 +85,7 @@ describe('pool', function () { }) it('can close multiple times on a pool', async function () { - const pool = new pg.Pool({ max: 1 }) + const pool = new gaussdb.Pool({ max: 1 }) const run = async () => { const cursor = new Cursor(text) const client = await pool.connect() diff --git a/packages/gaussdb-cursor/test/promises.js b/packages/gaussdb-cursor/test/promises.js index c26d2d2da..6fcdf6000 100644 --- a/packages/gaussdb-cursor/test/promises.js +++ b/packages/gaussdb-cursor/test/promises.js @@ -1,15 +1,15 @@ const assert = require('assert') const Cursor = require('../') -const pg = require('gaussdb') +const gaussdb = require('gaussdb') const text = 'SELECT generate_series as num FROM generate_series(0, 5)' describe('cursor using promises', function () { beforeEach(function (done) { - const client = (this.client = new pg.Client()) + const client = (this.client = new gaussdb.Client()) client.connect(done) - this.pgCursor = function (text, values) { + this.gaussdbCursor = function (text, values) { return client.query(new Cursor(text, values || [])) } }) @@ -19,13 +19,13 @@ describe('cursor using promises', function () { }) it('resolve with result', async function () { - const cursor = this.pgCursor(text) + const cursor = this.gaussdbCursor(text) const res = await cursor.read(6) assert.strictEqual(res.length, 6) }) it('reject with error', function (done) { - const cursor = this.pgCursor('select asdfasdf') + const cursor = this.gaussdbCursor('select asdfasdf') cursor.read(1).catch((err) => { assert(err) done() @@ -33,7 +33,7 @@ describe('cursor using promises', function () { }) it('read multiple times', async function () { - const cursor = this.pgCursor(text) + const cursor = this.gaussdbCursor(text) let res res = await cursor.read(2) diff --git a/packages/gaussdb-cursor/test/query-config.js b/packages/gaussdb-cursor/test/query-config.js index e9bcc5c71..03b4af0d1 100644 --- a/packages/gaussdb-cursor/test/query-config.js +++ b/packages/gaussdb-cursor/test/query-config.js @@ -1,11 +1,11 @@ 'use strict' const assert = require('assert') const Cursor = require('../') -const pg = require('gaussdb') +const gaussdb = require('gaussdb') describe('query config passed to result', () => { it('passes rowMode to result', (done) => { - const client = new pg.Client() + const client = new gaussdb.Client() client.connect() const text = 'SELECT generate_series as num FROM generate_series(0, 5)' const cursor = client.query(new Cursor(text, null, { rowMode: 'array' })) @@ -18,7 +18,7 @@ describe('query config passed to result', () => { }) it('passes types to result', (done) => { - const client = new pg.Client() + const client = new gaussdb.Client() client.connect() const text = 'SELECT generate_series as num FROM generate_series(0, 2)' const types = { diff --git a/packages/gaussdb-cursor/test/transactions.js b/packages/gaussdb-cursor/test/transactions.js index e08911609..ee62f26c2 100644 --- a/packages/gaussdb-cursor/test/transactions.js +++ b/packages/gaussdb-cursor/test/transactions.js @@ -1,12 +1,12 @@ const assert = require('assert') const Cursor = require('../') -const pg = require('gaussdb') +const gaussdb = require('gaussdb') // SKIP: 不支持 LISTEN/NOFITY statement // https://github.com/HuaweiCloudDeveloper/gaussdb-drivers/blob/master-dev/diff-gaussdb-postgres.md#%E4%B8%8D%E6%94%AF%E6%8C%81-listennofity-statement describe.skip('transactions', () => { it('can execute multiple statements in a transaction', async () => { - const client = new pg.Client() + const client = new gaussdb.Client() await client.connect() await client.query('begin') await client.query('CREATE TEMP TABLE foobar(id SERIAL PRIMARY KEY)') @@ -20,7 +20,7 @@ describe.skip('transactions', () => { }) it('can execute multiple statements in a transaction if ending cursor early', async () => { - const client = new pg.Client() + const client = new gaussdb.Client() await client.connect() await client.query('begin') await client.query('CREATE TEMP TABLE foobar(id SERIAL PRIMARY KEY)') @@ -31,7 +31,7 @@ describe.skip('transactions', () => { }) it('can execute multiple statements in a transaction if no data', async () => { - const client = new pg.Client() + const client = new gaussdb.Client() await client.connect() await client.query('begin') // create a cursor that has no data response diff --git a/packages/gaussdb-esm-test/common-js-imports.test.cjs b/packages/gaussdb-esm-test/common-js-imports.test.cjs index 34e70d57d..e17ec2959 100644 --- a/packages/gaussdb-esm-test/common-js-imports.test.cjs +++ b/packages/gaussdb-esm-test/common-js-imports.test.cjs @@ -20,9 +20,9 @@ for (const path of paths) { describe('pg-native', () => { it('should work with commonjs', async () => { - const pg = require('gaussdb') + const gaussdb = require('gaussdb') - const pool = new pg.native.Pool() + const pool = new gaussdb.native.Pool() const result = await pool.query('SELECT 1') assert.strictEqual(result.rowCount, 1) pool.end() diff --git a/packages/gaussdb-esm-test/gaussdb.test.js b/packages/gaussdb-esm-test/gaussdb.test.js index ac5085402..906b33055 100644 --- a/packages/gaussdb-esm-test/gaussdb.test.js +++ b/packages/gaussdb-esm-test/gaussdb.test.js @@ -1,6 +1,6 @@ import assert from 'node:assert' import { describe, it } from 'node:test' -import pg, { +import gaussdb, { Client, Pool, Connection, @@ -13,7 +13,7 @@ import pg, { TypeOverrides, } from 'gaussdb' -describe('pg', () => { +describe('gaussdb', () => { it('should export Client constructor', () => { assert.ok(new Client()) }) @@ -23,7 +23,7 @@ describe('pg', () => { }) it('should still provide default export', () => { - assert.ok(new pg.Pool()) + assert.ok(new gaussdb.Pool()) }) it('should export Connection constructor', () => { diff --git a/packages/gaussdb-protocol/src/inbound-parser.test.ts b/packages/gaussdb-protocol/src/inbound-parser.test.ts index cf8418d54..fe88ffe5e 100644 --- a/packages/gaussdb-protocol/src/inbound-parser.test.ts +++ b/packages/gaussdb-protocol/src/inbound-parser.test.ts @@ -245,7 +245,7 @@ const parseBuffers = async (buffers: Buffer[]): Promise => { return msgs } -describe('PgPacketStream', function () { +describe('GaussDBPacketStream', function () { testForMessage(authOkBuffer, expectedAuthenticationOkayMessage) testForMessage(plainPasswordBuffer, expectedPlainPasswordMessage) testForMessage(md5PasswordBuffer, expectedMD5PasswordMessage) diff --git a/packages/gaussdb-query-stream/src/index.ts b/packages/gaussdb-query-stream/src/index.ts index abb7f6234..205786ab3 100644 --- a/packages/gaussdb-query-stream/src/index.ts +++ b/packages/gaussdb-query-stream/src/index.ts @@ -36,7 +36,7 @@ class QueryStream extends Readable implements Submittable { this.handleError = this.cursor.handleError.bind(this.cursor) this.handleEmptyQuery = this.cursor.handleEmptyQuery.bind(this.cursor) - // pg client sets types via _result property + // gaussdb client sets types via _result property this._result = this.cursor._result } diff --git a/packages/gaussdb-query-stream/test/async-iterator.ts b/packages/gaussdb-query-stream/test/async-iterator.ts index db51296e6..9978dd3cd 100644 --- a/packages/gaussdb-query-stream/test/async-iterator.ts +++ b/packages/gaussdb-query-stream/test/async-iterator.ts @@ -1,5 +1,5 @@ import QueryStream from '../src' -import pg from 'gaussdb' +import gaussdb from 'gaussdb' import assert from 'assert' const queryText = 'SELECT * FROM generate_series(0, 200) num' @@ -9,7 +9,7 @@ if (!process.version.startsWith('v8')) { describe('Async iterator', () => { it('works', async () => { const stream = new QueryStream(queryText, []) - const client = new pg.Client() + const client = new gaussdb.Client() await client.connect() const query = client.query(stream) const rows = [] @@ -22,7 +22,7 @@ if (!process.version.startsWith('v8')) { it('can async iterate and then do a query afterwards', async () => { const stream = new QueryStream(queryText, []) - const client = new pg.Client() + const client = new gaussdb.Client() await client.connect() const query = client.query(stream) const iteratorRows = [] @@ -36,7 +36,7 @@ if (!process.version.startsWith('v8')) { }) it('can async iterate multiple times with a pool', async () => { - const pool = new pg.Pool({ max: 1 }) + const pool = new gaussdb.Pool({ max: 1 }) const allRows = [] const run = async () => { @@ -59,7 +59,7 @@ if (!process.version.startsWith('v8')) { }) it('can break out of iteration early', async () => { - const pool = new pg.Pool({ max: 1 }) + const pool = new gaussdb.Pool({ max: 1 }) const client = await pool.connect() const rows = [] for await (const row of client.query(new QueryStream(queryText, [], { batchSize: 1 }))) { @@ -80,7 +80,7 @@ if (!process.version.startsWith('v8')) { }) it('only returns rows on first iteration', async () => { - const pool = new pg.Pool({ max: 1 }) + const pool = new gaussdb.Pool({ max: 1 }) const client = await pool.connect() const rows = [] const stream = client.query(new QueryStream(queryText, [])) @@ -105,7 +105,7 @@ if (!process.version.startsWith('v8')) { }) it('can read with delays', async () => { - const pool = new pg.Pool({ max: 1 }) + const pool = new gaussdb.Pool({ max: 1 }) const client = await pool.connect() const rows = [] const stream = client.query(new QueryStream(queryText, [], { batchSize: 1 })) @@ -119,7 +119,7 @@ if (!process.version.startsWith('v8')) { }) it('supports breaking with low watermark', async function () { - const pool = new pg.Pool({ max: 1 }) + const pool = new gaussdb.Pool({ max: 1 }) const client = await pool.connect() for await (const _ of client.query(new QueryStream('select TRUE', [], { highWaterMark: 1 }))) break diff --git a/packages/gaussdb-query-stream/test/client-options.ts b/packages/gaussdb-query-stream/test/client-options.ts index 93f2f91d3..f1b982a7a 100644 --- a/packages/gaussdb-query-stream/test/client-options.ts +++ b/packages/gaussdb-query-stream/test/client-options.ts @@ -1,4 +1,4 @@ -import pg from 'gaussdb' +import gaussdb from 'gaussdb' import assert from 'assert' import QueryStream from '../src' @@ -7,7 +7,7 @@ describe('client options', function () { const types = { getTypeParser: () => (string) => string, } - const client = new pg.Client({ types }) + const client = new gaussdb.Client({ types }) client.connect() const stream = new QueryStream('SELECT * FROM generate_series(0, 10) num') const query = client.query(stream) diff --git a/packages/gaussdb-query-stream/test/helper.ts b/packages/gaussdb-query-stream/test/helper.ts index cf09e9c33..b2f65f9f6 100644 --- a/packages/gaussdb-query-stream/test/helper.ts +++ b/packages/gaussdb-query-stream/test/helper.ts @@ -1,8 +1,8 @@ -import pg from 'gaussdb' +import gaussdb from 'gaussdb' export default function (name, cb) { describe(name, function () { - const client = new pg.Client() + const client = new gaussdb.Client() before(function (done) { client.connect(done) diff --git a/packages/gaussdb-query-stream/test/issue-3.ts b/packages/gaussdb-query-stream/test/issue-3.ts index 511eb9584..3e06faa25 100644 --- a/packages/gaussdb-query-stream/test/issue-3.ts +++ b/packages/gaussdb-query-stream/test/issue-3.ts @@ -1,9 +1,9 @@ -import pg from 'gaussdb' +import gaussdb from 'gaussdb' import QueryStream from '../src' describe('end semantics race condition', function () { before(function (done) { - const client = new pg.Client() + const client = new gaussdb.Client() client.connect() client.on('drain', client.end.bind(client)) client.on('end', done) @@ -11,9 +11,9 @@ describe('end semantics race condition', function () { client.query('create table IF NOT EXISTS c(id int primary key references p)') }) it('works', function (done) { - const client1 = new pg.Client() + const client1 = new gaussdb.Client() client1.connect() - const client2 = new pg.Client() + const client2 = new gaussdb.Client() client2.connect() const qr = new QueryStream('INSERT INTO p DEFAULT VALUES RETURNING id') diff --git a/packages/gaussdb/Makefile b/packages/gaussdb/Makefile index cd0b41e37..ae866320b 100644 --- a/packages/gaussdb/Makefile +++ b/packages/gaussdb/Makefile @@ -54,9 +54,9 @@ test-pool: @find test/integration/connection-pool -name "*.js" | $(node-command) binary test-worker: - # this command only runs in node 18.x and above since there are + # this command only runs in node 18.x and above since there are # worker specific items missing from the node environment in lower versions - @if [[ $(shell node --version | sed 's/v//' | cut -d'.' -f1) -ge 18 ]]; then \ + @if [ $(shell node --version | sed 's/v//' | cut -d'.' -f1) -ge 18 ]; then \ echo "***Testing Cloudflare Worker support***"; \ yarn vitest run -c test/vitest.config.mts test/cloudflare/ --no-watch -- $(params); \ else \ diff --git a/packages/gaussdb/bench.js b/packages/gaussdb/bench.js index 7aaf7bced..3363742c2 100644 --- a/packages/gaussdb/bench.js +++ b/packages/gaussdb/bench.js @@ -1,4 +1,4 @@ -const pg = require('./lib') +const gaussdb = require('./lib') const params = { text: 'select typname, typnamespace, typowner, typlen, typbyval, typcategory, typispreferred, typisdefined, typdelim, typrelid, typelem, typarray from pg_type where typtypmod = $1 and typisdefined = $2', @@ -36,7 +36,7 @@ const bench = async (client, q, time) => { } const run = async () => { - const client = new pg.Client() + const client = new gaussdb.Client() await client.connect() console.log('start') await client.query('CREATE TEMP TABLE foobar(name TEXT, age NUMERIC)') diff --git a/packages/gaussdb/esm/index.mjs b/packages/gaussdb/esm/index.mjs index 587d80c1e..30eeba3fa 100644 --- a/packages/gaussdb/esm/index.mjs +++ b/packages/gaussdb/esm/index.mjs @@ -1,20 +1,20 @@ -// ESM wrapper for pg -import pg from '../lib/index.js' +// ESM wrapper for gaussdb +import gaussdb from '../lib/index.js' // Re-export all the properties -export const Client = pg.Client -export const Pool = pg.Pool -export const Connection = pg.Connection -export const types = pg.types -export const Query = pg.Query -export const DatabaseError = pg.DatabaseError -export const escapeIdentifier = pg.escapeIdentifier -export const escapeLiteral = pg.escapeLiteral -export const Result = pg.Result -export const TypeOverrides = pg.TypeOverrides +export const Client = gaussdb.Client +export const Pool = gaussdb.Pool +export const Connection = gaussdb.Connection +export const types = gaussdb.types +export const Query = gaussdb.Query +export const DatabaseError = gaussdb.DatabaseError +export const escapeIdentifier = gaussdb.escapeIdentifier +export const escapeLiteral = gaussdb.escapeLiteral +export const Result = gaussdb.Result +export const TypeOverrides = gaussdb.TypeOverrides // Also export the defaults -export const defaults = pg.defaults +export const defaults = gaussdb.defaults // Re-export the default -export default pg +export default gaussdb diff --git a/packages/gaussdb/lib/client.js b/packages/gaussdb/lib/client.js index ef999004e..a418079bd 100644 --- a/packages/gaussdb/lib/client.js +++ b/packages/gaussdb/lib/client.js @@ -254,7 +254,7 @@ class Client extends EventEmitter { _handleAuthMD5Password(msg) { this._checkPgPass(async () => { try { - const hashedPassword = await crypto.postgresMd5PasswordHash(this.user, this.password, msg.salt) + const hashedPassword = await crypto.gaussdbMd5PasswordHash(this.user, this.password, msg.salt) this.connection.password(hashedPassword) } catch (e) { this.emit('error', e) @@ -265,7 +265,7 @@ class Client extends EventEmitter { _handleAuthSHA256Password(msg) { this._checkPgPass(async () => { try { - const hashedPassword = await crypto.postgresSha256PasswordHash(this.user, this.password, msg.data) + const hashedPassword = await crypto.gaussdbSha256PasswordHash(this.user, this.password, msg.data) this.connection.password(hashedPassword) } catch (e) { this.emit('error', e) diff --git a/packages/gaussdb/lib/crypto/utils-legacy.js b/packages/gaussdb/lib/crypto/utils-legacy.js index 9b5819274..de43e2ec6 100644 --- a/packages/gaussdb/lib/crypto/utils-legacy.js +++ b/packages/gaussdb/lib/crypto/utils-legacy.js @@ -9,14 +9,14 @@ function md5(string) { } // See AuthenticationMD5Password at https://www.postgresql.org/docs/current/static/protocol-flow.html -function postgresMd5PasswordHash(user, password, salt) { +function gaussdbMd5PasswordHash(user, password, salt) { const inner = md5(password + user) const outer = md5(Buffer.concat([Buffer.from(inner), salt])) return 'md5' + outer } // See AuthenticationSHA256Password (based on similar approach to MD5) -function postgresSha256PasswordHash(user, password, salt) { +function gaussdbSha256PasswordHash(user, password, salt) { const inner = nodeCrypto .createHash('sha256') .update(password + user, 'utf-8') @@ -46,8 +46,8 @@ async function deriveKey(password, salt, iterations) { } module.exports = { - postgresMd5PasswordHash, - postgresSha256PasswordHash, + gaussdbMd5PasswordHash, + gaussdbSha256PasswordHash, randomBytes: nodeCrypto.randomBytes, deriveKey, sha256, diff --git a/packages/gaussdb/lib/crypto/utils-webcrypto.js b/packages/gaussdb/lib/crypto/utils-webcrypto.js index f13b32d08..d0bc3870b 100644 --- a/packages/gaussdb/lib/crypto/utils-webcrypto.js +++ b/packages/gaussdb/lib/crypto/utils-webcrypto.js @@ -2,8 +2,8 @@ const nodeCrypto = require('crypto') const { RFC5802Algorithm } = require('./rfc5802') module.exports = { - postgresMd5PasswordHash, - postgresSha256PasswordHash, + gaussdbMd5PasswordHash, + gaussdbSha256PasswordHash, randomBytes, deriveKey, sha256, @@ -50,13 +50,13 @@ async function md5(string) { } // See AuthenticationMD5Password at https://www.postgresql.org/docs/current/static/protocol-flow.html -async function postgresMd5PasswordHash(user, password, salt) { +async function gaussdbMd5PasswordHash(user, password, salt) { const inner = await md5(password + user) const outer = await md5(Buffer.concat([Buffer.from(inner), salt])) return 'md5' + outer } -async function postgresSha256PasswordHash(user, password, data) { +async function gaussdbSha256PasswordHash(user, password, data) { // Constants for data structure parsing const PASSWORD_METHOD_OFFSET = 0 const PASSWORD_METHOD_SIZE = 4 diff --git a/packages/gaussdb/lib/index.js b/packages/gaussdb/lib/index.js index 0805d3cf0..a97341f10 100644 --- a/packages/gaussdb/lib/index.js +++ b/packages/gaussdb/lib/index.js @@ -18,7 +18,7 @@ const poolFactory = (Client) => { } } -const PG = function (clientConstructor) { +const GAUSSDB = function (clientConstructor) { this.defaults = defaults this.Client = clientConstructor this.Query = this.Client.Query @@ -35,9 +35,9 @@ const PG = function (clientConstructor) { } if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') { - module.exports = new PG(require('./native')) + module.exports = new GAUSSDB(require('./native')) } else { - module.exports = new PG(Client) + module.exports = new GAUSSDB(Client) // lazy require native module...the native module may not have installed Object.defineProperty(module.exports, 'native', { @@ -46,7 +46,7 @@ if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') { get() { let native = null try { - native = new PG(require('./native')) + native = new GAUSSDB(require('./native')) } catch (err) { if (err.code !== 'MODULE_NOT_FOUND') { throw err diff --git a/packages/gaussdb/script/create-test-tables.js b/packages/gaussdb/script/create-test-tables.js index 76ba2dbe4..bee57780b 100644 --- a/packages/gaussdb/script/create-test-tables.js +++ b/packages/gaussdb/script/create-test-tables.js @@ -1,6 +1,6 @@ 'use strict' const args = require('../test/cli') -const pg = require('../lib') +const gaussdb = require('../lib') const people = [ { name: 'Aaron', age: 10 }, @@ -32,7 +32,7 @@ const people = [ ] async function run() { - const con = new pg.Client({ + const con = new gaussdb.Client({ user: args.user, password: args.password, host: args.host, diff --git a/packages/gaussdb/script/dump-db-types.js b/packages/gaussdb/script/dump-db-types.js index 46d1d1867..3b790eccf 100644 --- a/packages/gaussdb/script/dump-db-types.js +++ b/packages/gaussdb/script/dump-db-types.js @@ -1,11 +1,11 @@ 'use strict' -const pg = require('../lib') +const gaussdb = require('../lib') const args = require('../test/cli') const queries = ['select CURRENT_TIMESTAMP', "select interval '1 day' + interval '1 hour'", "select TIMESTAMP 'today'"] queries.forEach(function (query) { - const client = new pg.Client({ + const client = new gaussdb.Client({ user: args.user, database: args.database, password: args.password, diff --git a/packages/gaussdb/test/integration/client/api-tests.js b/packages/gaussdb/test/integration/client/api-tests.js index 53bb32074..ad149e30a 100644 --- a/packages/gaussdb/test/integration/client/api-tests.js +++ b/packages/gaussdb/test/integration/client/api-tests.js @@ -1,12 +1,12 @@ 'use strict' const helper = require('../test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') const suite = new helper.Suite() suite.test('null and undefined are both inserted as NULL', function (done) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, release) { assert(!err) @@ -41,7 +41,7 @@ suite.test('null and undefined are both inserted as NULL', function (done) { suite.test('pool callback behavior', (done) => { // test weird callback behavior with node-pool - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect(function (err) { assert(!err) arguments[1].emit('drain') @@ -51,7 +51,7 @@ suite.test('pool callback behavior', (done) => { }) suite.test('query timeout', (cb) => { - const pool = new pg.Pool({ query_timeout: 1000 }) + const pool = new gaussdb.Pool({ query_timeout: 1000 }) pool.connect().then((client) => { client.query( 'SELECT pg_sleep(2)', @@ -66,8 +66,9 @@ suite.test('query timeout', (cb) => { }) suite.test('query recover from timeout', (cb) => { - const pool = new pg.Pool({ query_timeout: 1000 }) + const pool = new gaussdb.Pool({ query_timeout: 1000 }) pool.connect().then((client) => { + // TODO: there is no function named `gaussdb_sleep` in GaussDB, so we use `pg_sleep` instead. client.query( 'SELECT pg_sleep(20)', assert.calls(function (err, result) { @@ -90,7 +91,7 @@ suite.test('query recover from timeout', (cb) => { }) suite.test('query no timeout', (cb) => { - const pool = new pg.Pool({ query_timeout: 10000 }) + const pool = new gaussdb.Pool({ query_timeout: 10000 }) pool.connect().then((client) => { client.query( 'SELECT pg_sleep(1)', @@ -104,7 +105,7 @@ suite.test('query no timeout', (cb) => { }) suite.test('query with timeout on query basis', (cb) => { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect().then((client) => { client.query( { text: 'SELECT pg_sleep(20)', query_timeout: 1000 }, @@ -152,7 +153,7 @@ suite.test('callback API', (done) => { }) suite.test('executing nested queries', function (done) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, release) { assert(!err) @@ -181,7 +182,7 @@ suite.test('executing nested queries', function (done) { suite.test('raises error if cannot connect', function () { const connectionString = 'gaussdb://sfalsdkf:asdf@localhost/ieieie' - const pool = new pg.Pool({ connectionString: connectionString }) + const pool = new gaussdb.Pool({ connectionString: connectionString }) pool.connect( assert.calls(function (err, client, done) { assert.ok(err, 'should have raised an error') @@ -191,7 +192,7 @@ suite.test('raises error if cannot connect', function () { }) suite.test('query errors are handled and do not bubble if callback is provided', function (done) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, release) { assert(!err) @@ -208,7 +209,7 @@ suite.test('query errors are handled and do not bubble if callback is provided', }) suite.test('callback is fired once and only once', function (done) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, release) { assert(!err) @@ -231,7 +232,7 @@ suite.test('callback is fired once and only once', function (done) { }) suite.test('can provide callback and config object', function (done) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, release) { assert(!err) @@ -252,7 +253,7 @@ suite.test('can provide callback and config object', function (done) { }) suite.test('can provide callback and config and parameters', function (done) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, release) { assert(!err) diff --git a/packages/gaussdb/test/integration/client/array-tests.js b/packages/gaussdb/test/integration/client/array-tests.js index 24814be91..53a08a693 100644 --- a/packages/gaussdb/test/integration/client/array-tests.js +++ b/packages/gaussdb/test/integration/client/array-tests.js @@ -1,11 +1,11 @@ 'use strict' const helper = require('./test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') const suite = new helper.Suite() -const pool = new pg.Pool() +const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, release) { @@ -50,7 +50,9 @@ pool.connect( assert(!err) client.query('CREATE TEMP TABLE why(names text[], numbors integer[])') client - .query(new pg.Query('INSERT INTO why(names, numbors) VALUES(\'{"aaron", "brian","a b c" }\', \'{1, 2, 3}\')')) + .query( + new gaussdb.Query('INSERT INTO why(names, numbors) VALUES(\'{"aaron", "brian","a b c" }\', \'{1, 2, 3}\')') + ) .on('error', console.log) suite.test('numbers', function (done) { // client.connection.on('message', console.log) diff --git a/packages/gaussdb/test/integration/client/async-stack-trace-tests.js b/packages/gaussdb/test/integration/client/async-stack-trace-tests.js index fd5b15da4..1f1f2c6d6 100644 --- a/packages/gaussdb/test/integration/client/async-stack-trace-tests.js +++ b/packages/gaussdb/test/integration/client/async-stack-trace-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('../test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb process.on('unhandledRejection', function (e) { console.error(e, e.stack) @@ -14,7 +14,7 @@ const NODE_MAJOR_VERSION = +process.versions.node.split('.')[0] if (NODE_MAJOR_VERSION >= 16) { suite.testAsync('promise API async stack trace in pool', async function outerFunction() { async function innerFunction() { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() await pool.query('SELECT test from nonexistent') } try { @@ -30,7 +30,7 @@ if (NODE_MAJOR_VERSION >= 16) { suite.testAsync('promise API async stack trace in client', async function outerFunction() { async function innerFunction() { - const client = new pg.Client() + const client = new gaussdb.Client() await client.connect() try { await client.query('SELECT test from nonexistent') diff --git a/packages/gaussdb/test/integration/client/big-simple-query-tests.js b/packages/gaussdb/test/integration/client/big-simple-query-tests.js index 2e66a1af8..9684a023d 100644 --- a/packages/gaussdb/test/integration/client/big-simple-query-tests.js +++ b/packages/gaussdb/test/integration/client/big-simple-query-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('./test-helper') -const Query = helper.pg.Query +const Query = helper.gaussdb.Query const assert = require('assert') const suite = new helper.Suite() diff --git a/packages/gaussdb/test/integration/client/configuration-tests.js b/packages/gaussdb/test/integration/client/configuration-tests.js index a5a11560d..32e39fdb1 100644 --- a/packages/gaussdb/test/integration/client/configuration-tests.js +++ b/packages/gaussdb/test/integration/client/configuration-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('./test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') const { Client } = helper @@ -14,7 +14,7 @@ for (const key in process.env) { } suite.test('default values are used in new clients', function () { - assert.same(pg.defaults, { + assert.same(gaussdb.defaults, { user: process.env.USER, database: undefined, password: null, @@ -30,7 +30,7 @@ suite.test('default values are used in new clients', function () { parseInputDatesAsUTC: false, }) - const client = new pg.Client() + const client = new gaussdb.Client() assert.same(client, { user: process.env.USER, password: null, @@ -40,11 +40,11 @@ suite.test('default values are used in new clients', function () { }) suite.test('modified values are passed to created clients', function () { - pg.defaults.user = 'boom' - pg.defaults.password = 'zap' - pg.defaults.host = 'blam' - pg.defaults.port = 1234 - pg.defaults.database = 'pow' + gaussdb.defaults.user = 'boom' + gaussdb.defaults.password = 'zap' + gaussdb.defaults.host = 'blam' + gaussdb.defaults.port = 1234 + gaussdb.defaults.database = 'pow' const client = new Client() assert.same(client, { @@ -58,7 +58,7 @@ suite.test('modified values are passed to created clients', function () { suite.test('database defaults to user when user is non-default', () => { { - pg.defaults.database = undefined + gaussdb.defaults.database = undefined const client = new Client({ user: 'foo', @@ -68,7 +68,7 @@ suite.test('database defaults to user when user is non-default', () => { } { - pg.defaults.database = 'bar' + gaussdb.defaults.database = 'bar' const client = new Client({ user: 'foo', diff --git a/packages/gaussdb/test/integration/client/connection-parameter-tests.js b/packages/gaussdb/test/integration/client/connection-parameter-tests.js index 943550484..49b70e952 100644 --- a/packages/gaussdb/test/integration/client/connection-parameter-tests.js +++ b/packages/gaussdb/test/integration/client/connection-parameter-tests.js @@ -1,7 +1,7 @@ const assert = require('assert') const helper = require('../test-helper') const suite = new helper.Suite() -const { Client } = helper.pg +const { Client } = helper.gaussdb suite.test('it sends options', async () => { const client = new Client({ diff --git a/packages/gaussdb/test/integration/client/custom-types-tests.js b/packages/gaussdb/test/integration/client/custom-types-tests.js index eb5fa892c..b109216da 100644 --- a/packages/gaussdb/test/integration/client/custom-types-tests.js +++ b/packages/gaussdb/test/integration/client/custom-types-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('./test-helper') -const Client = helper.pg.Client +const Client = helper.gaussdb.Client const suite = new helper.Suite() const assert = require('assert') diff --git a/packages/gaussdb/test/integration/client/error-handling-tests.js b/packages/gaussdb/test/integration/client/error-handling-tests.js index 8a6fc667f..dc59fbfce 100644 --- a/packages/gaussdb/test/integration/client/error-handling-tests.js +++ b/packages/gaussdb/test/integration/client/error-handling-tests.js @@ -2,10 +2,10 @@ const helper = require('./test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') -const Client = pg.Client -const DatabaseError = pg.DatabaseError +const Client = gaussdb.Client +const DatabaseError = gaussdb.DatabaseError const createErorrClient = function () { const client = helper.client() @@ -87,7 +87,7 @@ suite.test('query receives error on client shutdown', function (done) { } let queryError client.query( - new pg.Query(config), + new gaussdb.Query(config), assert.calls(function (err, res) { assert(err instanceof Error) queryError = err @@ -103,7 +103,7 @@ suite.test('query receives error on client shutdown', function (done) { }) const ensureFuture = function (testClient, done) { - const goodQuery = testClient.query(new pg.Query('select age from boom')) + const goodQuery = testClient.query(new gaussdb.Query('select age from boom')) assert.emits(goodQuery, 'row', function (row) { assert.equal(row.age, 28) done() @@ -117,7 +117,7 @@ suite.test('when query is parsing', (done) => { // this query wont parse since there isn't a table named bang const query = client.query( - new pg.Query({ + new gaussdb.Query({ text: 'select * from bang where name = $1', values: ['0'], }) @@ -134,7 +134,7 @@ suite.test('when a query is binding', function (done) { client.query({ text: 'CREATE TEMP TABLE boom(age integer); INSERT INTO boom (age) VALUES (28);' }) const query = client.query( - new pg.Query({ + new gaussdb.Query({ text: 'select * from boom where age = $1', values: ['asldkfjasdf'], }) @@ -214,7 +214,7 @@ suite.test('non-query error', function (done) { suite.test('within a simple query', (done) => { const client = createErorrClient() - const query = client.query(new pg.Query("select eeeee from yodas_dsflsd where pixistix = 'zoiks!!!'")) + const query = client.query(new gaussdb.Query("select eeeee from yodas_dsflsd where pixistix = 'zoiks!!!'")) assert.emits(query, 'error', function (error) { if (!helper.config.native) { diff --git a/packages/gaussdb/test/integration/client/field-name-escape-tests.js b/packages/gaussdb/test/integration/client/field-name-escape-tests.js index 4261c198e..391ed9054 100644 --- a/packages/gaussdb/test/integration/client/field-name-escape-tests.js +++ b/packages/gaussdb/test/integration/client/field-name-escape-tests.js @@ -1,8 +1,8 @@ -const pg = require('./test-helper').pg +const gaussdb = require('./test-helper').gaussdb const sql = 'SELECT 1 AS "\\\'/*", 2 AS "\\\'*/\n + process.exit(-1)] = null;\n//"' -const client = new pg.Client() +const client = new gaussdb.Client() client.connect() client.query(sql, function (err, res) { if (err) throw err diff --git a/packages/gaussdb/test/integration/client/huge-numeric-tests.js b/packages/gaussdb/test/integration/client/huge-numeric-tests.js index fd4c28295..5f71bd15f 100644 --- a/packages/gaussdb/test/integration/client/huge-numeric-tests.js +++ b/packages/gaussdb/test/integration/client/huge-numeric-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('./test-helper') -const pool = new helper.pg.Pool() +const pool = new helper.gaussdb.Pool() const assert = require('assert') pool.connect( diff --git a/packages/gaussdb/test/integration/client/json-type-parsing-tests.js b/packages/gaussdb/test/integration/client/json-type-parsing-tests.js index 6efd37b80..7282779b4 100644 --- a/packages/gaussdb/test/integration/client/json-type-parsing-tests.js +++ b/packages/gaussdb/test/integration/client/json-type-parsing-tests.js @@ -6,7 +6,7 @@ // https://github.com/HuaweiCloudDeveloper/gaussdb-drivers/blob/master-dev/diff-gaussdb-postgres.md#%E4%B8%8D%E6%94%AF%E6%8C%81-%E4%B8%B4%E6%97%B6%E8%A1%A8serial /* -const pool = new helper.pg.Pool() +const pool = new helper.gaussdb.Pool() pool.connect( assert.success(function (client, done) { helper.versionGTE( diff --git a/packages/gaussdb/test/integration/client/no-row-result-tests.js b/packages/gaussdb/test/integration/client/no-row-result-tests.js index d53470040..e32e331e8 100644 --- a/packages/gaussdb/test/integration/client/no-row-result-tests.js +++ b/packages/gaussdb/test/integration/client/no-row-result-tests.js @@ -1,8 +1,8 @@ 'use strict' const helper = require('./test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const suite = new helper.Suite() -const pool = new pg.Pool() +const pool = new gaussdb.Pool() const assert = require('assert') suite.test('can access results when no rows are returned', function (done) { @@ -15,7 +15,7 @@ suite.test('can access results when no rows are returned', function (done) { pool.connect( assert.success(function (client, release) { - const q = new pg.Query('select $1::text as val limit 0', ['hi']) + const q = new gaussdb.Query('select $1::text as val limit 0', ['hi']) const query = client.query( q, assert.success(function (result) { diff --git a/packages/gaussdb/test/integration/client/parse-int-8-tests.js b/packages/gaussdb/test/integration/client/parse-int-8-tests.js index 7c8af2b84..0cde0154f 100644 --- a/packages/gaussdb/test/integration/client/parse-int-8-tests.js +++ b/packages/gaussdb/test/integration/client/parse-int-8-tests.js @@ -1,7 +1,7 @@ 'use strict' // const helper = require('../test-helper') -// const pg = helper.pg +// const gaussdb = helper.gaussdb // const suite = new helper.Suite() // const assert = require('assert') @@ -9,12 +9,12 @@ // https://github.com/HuaweiCloudDeveloper/gaussdb-drivers/blob/master-dev/diff-gaussdb-postgres.md#%E4%B8%8D%E6%94%AF%E6%8C%81-%E4%B8%B4%E6%97%B6%E8%A1%A8serial /* -const pool = new pg.Pool(helper.config) +const pool = new gaussdb.Pool(helper.config) suite.test('ability to turn on and off parser', function () { if (helper.args.binary) return false pool.connect( assert.success(function (client, done) { - pg.defaults.parseInt8 = true + gaussdb.defaults.parseInt8 = true client.query('CREATE TEMP TABLE asdf(id SERIAL PRIMARY KEY)') client.query( 'SELECT COUNT(*) as "count", \'{1,2,3}\'::bigint[] as array FROM asdf', @@ -23,7 +23,7 @@ suite.test('ability to turn on and off parser', function () { assert.strictEqual(1, res.rows[0].array[0]) assert.strictEqual(2, res.rows[0].array[1]) assert.strictEqual(3, res.rows[0].array[2]) - pg.defaults.parseInt8 = false + gaussdb.defaults.parseInt8 = false client.query( 'SELECT COUNT(*) as "count", \'{1,2,3}\'::bigint[] as array FROM asdf', assert.success(function (res) { diff --git a/packages/gaussdb/test/integration/client/prepared-statement-tests.js b/packages/gaussdb/test/integration/client/prepared-statement-tests.js index 9047eae6c..5a7ec104d 100644 --- a/packages/gaussdb/test/integration/client/prepared-statement-tests.js +++ b/packages/gaussdb/test/integration/client/prepared-statement-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('./test-helper') -const Query = helper.pg.Query +const Query = helper.gaussdb.Query const assert = require('assert') const suite = new helper.Suite() @@ -128,15 +128,15 @@ const suite = new helper.Suite() const client = helper.client() client.query('CREATE TEMP TABLE zoom(name varchar(100));') client.query("INSERT INTO zoom (name) VALUES ('zed')") - client.query("INSERT INTO zoom (name) VALUES ('postgres')") - client.query("INSERT INTO zoom (name) VALUES ('node postgres')") + client.query("INSERT INTO zoom (name) VALUES ('gaussdb')") + client.query("INSERT INTO zoom (name) VALUES ('node gaussdb')") const checkForResults = function (q) { assert.emits(q, 'row', function (row) { - assert.equal(row.name, 'node postgres') + assert.equal(row.name, 'gaussdb') assert.emits(q, 'row', function (row) { - assert.equal(row.name, 'postgres') + assert.equal(row.name, 'node gaussdb') assert.emits(q, 'row', function (row) { assert.equal(row.name, 'zed') diff --git a/packages/gaussdb/test/integration/client/promise-api-tests.js b/packages/gaussdb/test/integration/client/promise-api-tests.js index a536ce44a..e3839573c 100644 --- a/packages/gaussdb/test/integration/client/promise-api-tests.js +++ b/packages/gaussdb/test/integration/client/promise-api-tests.js @@ -1,27 +1,27 @@ 'use strict' const helper = require('./test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') const suite = new helper.Suite() suite.test('valid connection completes promise', () => { - const client = new pg.Client() + const client = new gaussdb.Client() return client.connect().then(() => { return client.end().then(() => {}) }) }) suite.test('valid connection completes promise', () => { - const client = new pg.Client() + const client = new gaussdb.Client() return client.connect().then(() => { return client.end().then(() => {}) }) }) suite.test('invalid connection rejects promise', (done) => { - const client = new pg.Client({ host: 'alksdjflaskdfj', port: 1234 }) + const client = new gaussdb.Client({ host: 'alksdjflaskdfj', port: 1234 }) return client.connect().catch((e) => { assert(e instanceof Error) done() @@ -29,7 +29,7 @@ suite.test('invalid connection rejects promise', (done) => { }) suite.test('connected client does not reject promise after connection', (done) => { - const client = new pg.Client() + const client = new gaussdb.Client() return client.connect().then(() => { setTimeout(() => { client.on('error', (e) => { diff --git a/packages/gaussdb/test/integration/client/query-as-promise-tests.js b/packages/gaussdb/test/integration/client/query-as-promise-tests.js index 8e1ba5c71..afbb0695e 100644 --- a/packages/gaussdb/test/integration/client/query-as-promise-tests.js +++ b/packages/gaussdb/test/integration/client/query-as-promise-tests.js @@ -1,7 +1,7 @@ 'use strict' const bluebird = require('bluebird') const helper = require('../test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') process.on('unhandledRejection', function (e) { @@ -12,7 +12,7 @@ process.on('unhandledRejection', function (e) { const suite = new helper.Suite() suite.test('promise API', (cb) => { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect().then((client) => { client .query('SELECT $1::text as name', ['foo']) @@ -34,7 +34,7 @@ suite.test('promise API', (cb) => { }) suite.test('promise API with configurable promise type', (cb) => { - const client = new pg.Client({ Promise: bluebird }) + const client = new gaussdb.Client({ Promise: bluebird }) const connectPromise = client.connect() assert(connectPromise instanceof bluebird, 'Client connect() returns configured promise') diff --git a/packages/gaussdb/test/integration/client/query-column-names-tests.js b/packages/gaussdb/test/integration/client/query-column-names-tests.js index d64e876b8..c5cb09e0a 100644 --- a/packages/gaussdb/test/integration/client/query-column-names-tests.js +++ b/packages/gaussdb/test/integration/client/query-column-names-tests.js @@ -1,10 +1,10 @@ 'use strict' const helper = require('../test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') new helper.Suite().test('support for complex column names', function () { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.success(function (client, done) { client.query('CREATE TEMP TABLE t ( "complex\'\'column" TEXT )') diff --git a/packages/gaussdb/test/integration/client/query-error-handling-prepared-statement-tests.js b/packages/gaussdb/test/integration/client/query-error-handling-prepared-statement-tests.js index 13ecf4b53..b49a68485 100644 --- a/packages/gaussdb/test/integration/client/query-error-handling-prepared-statement-tests.js +++ b/packages/gaussdb/test/integration/client/query-error-handling-prepared-statement-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('./test-helper') -const Query = helper.pg.Query +const Query = helper.gaussdb.Query const { Client } = helper const assert = require('assert') diff --git a/packages/gaussdb/test/integration/client/query-error-handling-tests.js b/packages/gaussdb/test/integration/client/query-error-handling-tests.js index eaceec03e..ef87f2f34 100644 --- a/packages/gaussdb/test/integration/client/query-error-handling-tests.js +++ b/packages/gaussdb/test/integration/client/query-error-handling-tests.js @@ -1,7 +1,7 @@ 'use strict' const helper = require('./test-helper') -const Query = helper.pg.Query -const DatabaseError = helper.pg.DatabaseError +const Query = helper.gaussdb.Query +const DatabaseError = helper.gaussdb.DatabaseError const assert = require('assert') const { Client } = helper const suite = new helper.Suite() diff --git a/packages/gaussdb/test/integration/client/quick-disconnect-tests.js b/packages/gaussdb/test/integration/client/quick-disconnect-tests.js index 8c14214da..91d021aea 100644 --- a/packages/gaussdb/test/integration/client/quick-disconnect-tests.js +++ b/packages/gaussdb/test/integration/client/quick-disconnect-tests.js @@ -3,6 +3,6 @@ // const helper = require('./test-helper') -const client = new helper.pg.Client(helper.config) +const client = new helper.gaussdb.Client(helper.config) client.connect() client.end() diff --git a/packages/gaussdb/test/integration/client/result-metadata-tests.js b/packages/gaussdb/test/integration/client/result-metadata-tests.js index fe6eaf919..9aedd50ba 100644 --- a/packages/gaussdb/test/integration/client/result-metadata-tests.js +++ b/packages/gaussdb/test/integration/client/result-metadata-tests.js @@ -1,9 +1,9 @@ 'use strict' const helper = require('./test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') -const pool = new pg.Pool() +const pool = new gaussdb.Pool() new helper.Suite().test('should return insert metadata', function () { pool.connect( assert.calls(function (err, client, done) { diff --git a/packages/gaussdb/test/integration/client/sasl-scram-tests.js b/packages/gaussdb/test/integration/client/sasl-scram-tests.js index ce5d63e65..be34ed6ef 100644 --- a/packages/gaussdb/test/integration/client/sasl-scram-tests.js +++ b/packages/gaussdb/test/integration/client/sasl-scram-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('./../test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const suite = new helper.Suite() const { native } = helper.args const assert = require('assert') @@ -46,7 +46,7 @@ if (!config.user || !config.password) { } suite.testAsync('can connect using sasl/scram with channel binding enabled (if using SSL)', async () => { - const client = new pg.Client({ ...config, enableChannelBinding: true }) + const client = new gaussdb.Client({ ...config, enableChannelBinding: true }) let usingChannelBinding = false let hasPeerCert = false client.connection.once('authenticationSASLContinue', () => { @@ -59,7 +59,7 @@ suite.testAsync('can connect using sasl/scram with channel binding enabled (if u }) suite.testAsync('can connect using sasl/scram with channel binding disabled', async () => { - const client = new pg.Client({ ...config, enableChannelBinding: false }) + const client = new gaussdb.Client({ ...config, enableChannelBinding: false }) let usingSASLWithoutChannelBinding = false client.connection.once('authenticationSASLContinue', () => { usingSASLWithoutChannelBinding = client.saslSession.mechanism === 'SCRAM-SHA-256' @@ -70,7 +70,7 @@ suite.testAsync('can connect using sasl/scram with channel binding disabled', as }) suite.testAsync('sasl/scram fails when password is wrong', async () => { - const client = new pg.Client({ + const client = new gaussdb.Client({ ...config, password: config.password + 'append-something-to-make-it-bad', }) @@ -89,7 +89,7 @@ suite.testAsync('sasl/scram fails when password is wrong', async () => { }) suite.testAsync('sasl/scram fails when password is empty', async () => { - const client = new pg.Client({ + const client = new gaussdb.Client({ ...config, // We use a password function here so the connection defaults do not // override the empty string value with one from process.env.PGPASSWORD diff --git a/packages/gaussdb/test/integration/client/sha256-password-tests.js b/packages/gaussdb/test/integration/client/sha256-password-tests.js index 4bf802f77..b783c2866 100644 --- a/packages/gaussdb/test/integration/client/sha256-password-tests.js +++ b/packages/gaussdb/test/integration/client/sha256-password-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('./../test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const suite = new helper.Suite() const { native } = helper.args const assert = require('assert') @@ -46,7 +46,7 @@ if (!config.user || !config.password) { } suite.testAsync('can connect using sha256 password authentication', async () => { - const client = new pg.Client(config) + const client = new gaussdb.Client(config) let usingSha256 = false client.connection.once('authenticationSHA256Password', () => { usingSha256 = true @@ -62,7 +62,7 @@ suite.testAsync('can connect using sha256 password authentication', async () => }) suite.testAsync('sha256 authentication fails when password is wrong', async () => { - const client = new pg.Client({ + const client = new gaussdb.Client({ ...config, password: config.password + 'append-something-to-make-it-bad', }) @@ -81,7 +81,7 @@ suite.testAsync('sha256 authentication fails when password is wrong', async () = }) suite.testAsync('sha256 authentication fails when password is empty', async () => { - const client = new pg.Client({ + const client = new gaussdb.Client({ ...config, // use a password function to simulate empty password password: () => '', diff --git a/packages/gaussdb/test/integration/client/simple-query-tests.js b/packages/gaussdb/test/integration/client/simple-query-tests.js index e25bbb24d..0a647a50d 100644 --- a/packages/gaussdb/test/integration/client/simple-query-tests.js +++ b/packages/gaussdb/test/integration/client/simple-query-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('./test-helper') -const Query = helper.pg.Query +const Query = helper.gaussdb.Query const assert = require('assert') const suite = new helper.Suite() const test = suite.test.bind(suite) diff --git a/packages/gaussdb/test/integration/client/ssl-tests.js b/packages/gaussdb/test/integration/client/ssl-tests.js index 945abe5b3..ade0acd1c 100644 --- a/packages/gaussdb/test/integration/client/ssl-tests.js +++ b/packages/gaussdb/test/integration/client/ssl-tests.js @@ -16,7 +16,7 @@ suite.test('can connect with ssl', function () { rejectUnauthorized: false, }, } - const client = new helper.pg.Client(config) + const client = new helper.gaussdb.Client(config) client.connect( assert.success(function () { client.query( diff --git a/packages/gaussdb/test/integration/client/timezone-tests.js b/packages/gaussdb/test/integration/client/timezone-tests.js index df87dcc74..32cc64f45 100644 --- a/packages/gaussdb/test/integration/client/timezone-tests.js +++ b/packages/gaussdb/test/integration/client/timezone-tests.js @@ -7,7 +7,7 @@ process.env.TZ = 'Europe/Berlin' const date = new Date() -const pool = new helper.pg.Pool() +const pool = new helper.gaussdb.Pool() const suite = new helper.Suite() pool.connect(function (err, client, done) { diff --git a/packages/gaussdb/test/integration/client/transaction-tests.js b/packages/gaussdb/test/integration/client/transaction-tests.js index feb178fef..3472a1f52 100644 --- a/packages/gaussdb/test/integration/client/transaction-tests.js +++ b/packages/gaussdb/test/integration/client/transaction-tests.js @@ -1,10 +1,10 @@ 'use strict' const helper = require('./test-helper') const suite = new helper.Suite() -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') -const client = new pg.Client() +const client = new gaussdb.Client() client.connect( assert.success(function () { client.query('begin') @@ -65,7 +65,7 @@ client.connect( ) suite.test('gh#36', function (cb) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.success(function (client, done) { client.query('BEGIN') diff --git a/packages/gaussdb/test/integration/client/type-coercion-tests.js b/packages/gaussdb/test/integration/client/type-coercion-tests.js index 42958a94e..e4584e3de 100644 --- a/packages/gaussdb/test/integration/client/type-coercion-tests.js +++ b/packages/gaussdb/test/integration/client/type-coercion-tests.js @@ -1,11 +1,11 @@ 'use strict' const helper = require('./test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const suite = new helper.Suite() const assert = require('assert') const testForTypeCoercion = function (type) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() suite.test(`test type coercion ${type.name}`, (cb) => { pool.connect(function (err, client, done) { assert(!err) @@ -24,7 +24,7 @@ const testForTypeCoercion = function (type) { ) const query = client.query( - new pg.Query({ + new gaussdb.Query({ name: 'get type ' + type.name, text: 'select col from test_type', }) @@ -154,7 +154,7 @@ suite.test('timestamptz round trip', function (cb) { values: ['now', now], }) const result = client.query( - new pg.Query({ + new gaussdb.Query({ name: 'get date', text: 'select * from date_tests where name = $1', values: ['now'], @@ -178,7 +178,7 @@ suite.test('timestamptz round trip', function (cb) { }) suite.test('selecting nulls', (cb) => { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, done) { assert.ifError(err) diff --git a/packages/gaussdb/test/integration/client/type-parser-override-tests.js b/packages/gaussdb/test/integration/client/type-parser-override-tests.js index 883e61bad..a099b8eb2 100644 --- a/packages/gaussdb/test/integration/client/type-parser-override-tests.js +++ b/packages/gaussdb/test/integration/client/type-parser-override-tests.js @@ -15,7 +15,7 @@ function testTypeParser(client, expectedResult, done) { ) } -const pool = new helper.pg.Pool(helper.config) +const pool = new helper.gaussdb.Pool(helper.config) pool.connect( assert.success(function (client1, done1) { pool.connect( diff --git a/packages/gaussdb/test/integration/connection-pool/connection-pool-size-tests.js b/packages/gaussdb/test/integration/connection-pool/connection-pool-size-tests.js index 260e922d3..8c70e37c7 100644 --- a/packages/gaussdb/test/integration/connection-pool/connection-pool-size-tests.js +++ b/packages/gaussdb/test/integration/connection-pool/connection-pool-size-tests.js @@ -6,7 +6,7 @@ const suite = new helper.Suite() const testPoolSize = function (max) { suite.testAsync(`test ${max} queries executed on a pool rapidly`, async () => { - const pool = new helper.pg.Pool({ max: 10 }) + const pool = new helper.gaussdb.Pool({ max: 10 }) let count = 0 diff --git a/packages/gaussdb/test/integration/connection-pool/error-tests.js b/packages/gaussdb/test/integration/connection-pool/error-tests.js index d5857b583..ecd7955b5 100644 --- a/packages/gaussdb/test/integration/connection-pool/error-tests.js +++ b/packages/gaussdb/test/integration/connection-pool/error-tests.js @@ -1,18 +1,18 @@ 'use strict' const helper = require('./test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const native = helper.args.native const assert = require('assert') const suite = new helper.Suite() suite.test('connecting to invalid port', (cb) => { - const pool = new pg.Pool({ port: 13801 }) + const pool = new gaussdb.Pool({ port: 13801 }) pool.connect().catch((e) => cb()) }) suite.test('errors emitted on checked-out clients', (cb) => { // make pool hold 2 clients - const pool = new pg.Pool({ max: 2 }) + const pool = new gaussdb.Pool({ max: 2 }) // get first client pool.connect( assert.success(function (client, done) { @@ -59,7 +59,7 @@ suite.test('errors emitted on checked-out clients', (cb) => { }) suite.test('connection-level errors cause queued queries to fail', (cb) => { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.success((client, done) => { client.query( @@ -99,7 +99,7 @@ suite.test('connection-level errors cause queued queries to fail', (cb) => { }) suite.test('connection-level errors cause future queries to fail', (cb) => { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.success((client, done) => { client.query( @@ -138,7 +138,7 @@ suite.test('connection-level errors cause future queries to fail', (cb) => { }) suite.test('handles socket error during pool.query and destroys it immediately', (cb) => { - const pool = new pg.Pool({ max: 1 }) + const pool = new gaussdb.Pool({ max: 1 }) if (native) { pool.query('SELECT pg_sleep(10)', [], (err) => { diff --git a/packages/gaussdb/test/integration/connection-pool/idle-timeout-tests.js b/packages/gaussdb/test/integration/connection-pool/idle-timeout-tests.js index bc67f856f..bf5accc0d 100644 --- a/packages/gaussdb/test/integration/connection-pool/idle-timeout-tests.js +++ b/packages/gaussdb/test/integration/connection-pool/idle-timeout-tests.js @@ -4,7 +4,7 @@ const assert = require('assert') new helper.Suite().test('idle timeout', function () { const config = Object.assign({}, helper.config, { idleTimeoutMillis: 50 }) - const pool = new helper.pg.Pool(config) + const pool = new helper.gaussdb.Pool(config) pool.connect( assert.calls(function (err, client, done) { assert(!err) diff --git a/packages/gaussdb/test/integration/connection-pool/native-instance-tests.js b/packages/gaussdb/test/integration/connection-pool/native-instance-tests.js index 6f713411d..e3b18f2b1 100644 --- a/packages/gaussdb/test/integration/connection-pool/native-instance-tests.js +++ b/packages/gaussdb/test/integration/connection-pool/native-instance-tests.js @@ -1,10 +1,10 @@ 'use strict' const helper = require('./../test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const native = helper.args.native const assert = require('assert') -const pool = new pg.Pool() +const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, done) { diff --git a/packages/gaussdb/test/integration/connection-pool/tls-tests.js b/packages/gaussdb/test/integration/connection-pool/tls-tests.js index f85941d45..46b238e4d 100644 --- a/packages/gaussdb/test/integration/connection-pool/tls-tests.js +++ b/packages/gaussdb/test/integration/connection-pool/tls-tests.js @@ -3,13 +3,13 @@ const fs = require('fs') const helper = require('./test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const suite = new helper.Suite() if (process.env.PG_CLIENT_CERT_TEST) { suite.testAsync('client certificate', async () => { - const pool = new pg.Pool({ + const pool = new gaussdb.Pool({ ssl: { ca: fs.readFileSync(process.env.PGSSLROOTCERT), cert: fs.readFileSync(process.env.PGSSLCERT), diff --git a/packages/gaussdb/test/integration/connection-pool/yield-support-tests.js b/packages/gaussdb/test/integration/connection-pool/yield-support-tests.js index d3b33cc21..75792f116 100644 --- a/packages/gaussdb/test/integration/connection-pool/yield-support-tests.js +++ b/packages/gaussdb/test/integration/connection-pool/yield-support-tests.js @@ -3,7 +3,7 @@ const helper = require('./test-helper') const co = require('co') const assert = require('assert') -const pool = new helper.pg.Pool() +const pool = new helper.gaussdb.Pool() new helper.Suite().test( 'using coroutines works with promises', co.wrap(function* () { diff --git a/packages/gaussdb/test/integration/domain-tests.js b/packages/gaussdb/test/integration/domain-tests.js index ae63a4a8e..6950d1bca 100644 --- a/packages/gaussdb/test/integration/domain-tests.js +++ b/packages/gaussdb/test/integration/domain-tests.js @@ -1,11 +1,11 @@ 'use strict' const helper = require('./test-helper') -const Query = helper.pg.Query +const Query = helper.gaussdb.Query const suite = new helper.Suite() const assert = require('assert') -const Pool = helper.pg.Pool +const Pool = helper.gaussdb.Pool suite.test('no domain', function (cb) { assert(!process.domain) diff --git a/packages/gaussdb/test/integration/gh-issues/130-tests.js b/packages/gaussdb/test/integration/gh-issues/130-tests.js index 88c4dfb79..e02365274 100644 --- a/packages/gaussdb/test/integration/gh-issues/130-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/130-tests.js @@ -3,9 +3,9 @@ const helper = require('../test-helper') const exec = require('child_process').exec const assert = require('assert') -helper.pg.defaults.poolIdleTimeout = 1000 +helper.gaussdb.defaults.poolIdleTimeout = 1000 -const pool = new helper.pg.Pool() +const pool = new helper.gaussdb.Pool() pool.connect(function (err, client, done) { assert.ifError(err) client.once('error', function (err) { diff --git a/packages/gaussdb/test/integration/gh-issues/131-tests.js b/packages/gaussdb/test/integration/gh-issues/131-tests.js index b2144e6f4..4405b6fce 100644 --- a/packages/gaussdb/test/integration/gh-issues/131-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/131-tests.js @@ -1,19 +1,19 @@ 'use strict' const helper = require('../test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') const suite = new helper.Suite() suite.test('parsing array decimal results', function (done) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.calls(function (err, client, release) { assert(!err) client.query('CREATE TEMP TABLE why(names text[], numbors integer[], decimals double precision[])') client .query( - new pg.Query( + new gaussdb.Query( 'INSERT INTO why(names, numbors, decimals) VALUES(\'{"aaron", "brian","a b c" }\', \'{1, 2, 3}\', \'{.1, 0.05, 3.654}\')' ) ) diff --git a/packages/gaussdb/test/integration/gh-issues/1382-tests.js b/packages/gaussdb/test/integration/gh-issues/1382-tests.js index ea2a60f77..c933cbb04 100644 --- a/packages/gaussdb/test/integration/gh-issues/1382-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/1382-tests.js @@ -4,7 +4,7 @@ const helper = require('./../test-helper') const suite = new helper.Suite() suite.test('calling end during active query should return a promise', (done) => { - const client = new helper.pg.Client() + const client = new helper.gaussdb.Client() let callCount = 0 // ensure both the query rejects and the end promise resolves const after = () => { @@ -19,7 +19,7 @@ suite.test('calling end during active query should return a promise', (done) => }) suite.test('calling end during an active query should call end callback', (done) => { - const client = new helper.pg.Client() + const client = new helper.gaussdb.Client() let callCount = 0 // ensure both the query rejects and the end callback fires const after = () => { diff --git a/packages/gaussdb/test/integration/gh-issues/1542-tests.js b/packages/gaussdb/test/integration/gh-issues/1542-tests.js index 6ad075b22..897732b36 100644 --- a/packages/gaussdb/test/integration/gh-issues/1542-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/1542-tests.js @@ -5,17 +5,17 @@ const assert = require('assert') const suite = new helper.Suite() suite.testAsync('BoundPool can be subclassed', async () => { - const Pool = helper.pg.Pool + const Pool = helper.gaussdb.Pool class SubPool extends Pool {} const subPool = new SubPool() const client = await subPool.connect() client.release() await subPool.end() - assert(subPool instanceof helper.pg.Pool) + assert(subPool instanceof helper.gaussdb.Pool) }) -suite.test('calling pg.Pool without new throws', () => { - const Pool = helper.pg.Pool +suite.test('calling gaussdb.Pool without new throws', () => { + const Pool = helper.gaussdb.Pool assert.throws(() => { Pool() }) diff --git a/packages/gaussdb/test/integration/gh-issues/1854-tests.js b/packages/gaussdb/test/integration/gh-issues/1854-tests.js index 6e345f4cf..0cf71665c 100644 --- a/packages/gaussdb/test/integration/gh-issues/1854-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/1854-tests.js @@ -8,7 +8,7 @@ suite.test('Parameter serialization errors should not cause query to hang', (don // pg-native cannot handle non-string parameters so skip this entirely return done() } - const client = new helper.pg.Client() + const client = new helper.gaussdb.Client() const expectedErr = new Error('Serialization error') client .connect() diff --git a/packages/gaussdb/test/integration/gh-issues/1992-tests.js b/packages/gaussdb/test/integration/gh-issues/1992-tests.js index abb2167af..6e28f179a 100644 --- a/packages/gaussdb/test/integration/gh-issues/1992-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/1992-tests.js @@ -5,6 +5,6 @@ const assert = require('assert') const suite = new helper.Suite() suite.test('Native should not be enumerable', () => { - const keys = Object.keys(helper.pg) + const keys = Object.keys(helper.gaussdb) assert.strictEqual(keys.indexOf('native'), -1) }) diff --git a/packages/gaussdb/test/integration/gh-issues/2056-tests.js b/packages/gaussdb/test/integration/gh-issues/2056-tests.js index cf1be338f..aede4e315 100644 --- a/packages/gaussdb/test/integration/gh-issues/2056-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2056-tests.js @@ -5,7 +5,7 @@ const assert = require('assert') const suite = new helper.Suite() suite.test('All queries should return a result array', (done) => { - const client = new helper.pg.Client() + const client = new helper.gaussdb.Client() client.connect() const promises = [] promises.push(client.query('CREATE TEMP TABLE foo(bar TEXT)')) diff --git a/packages/gaussdb/test/integration/gh-issues/2064-tests.js b/packages/gaussdb/test/integration/gh-issues/2064-tests.js index 0878b7941..e8b5db795 100644 --- a/packages/gaussdb/test/integration/gh-issues/2064-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2064-tests.js @@ -8,23 +8,23 @@ const suite = new helper.Suite() const password = 'FAIL THIS TEST' suite.test('Password should not exist in toString() output', () => { - const pool = new helper.pg.Pool({ password }) - const client = new helper.pg.Client({ password }) + const pool = new helper.gaussdb.Pool({ password }) + const client = new helper.gaussdb.Client({ password }) assert(pool.toString().indexOf(password) === -1) assert(client.toString().indexOf(password) === -1) }) suite.test('Password should not exist in util.inspect output', () => { - const pool = new helper.pg.Pool({ password }) - const client = new helper.pg.Client({ password }) + const pool = new helper.gaussdb.Pool({ password }) + const client = new helper.gaussdb.Client({ password }) const depth = 20 assert(util.inspect(pool, { depth }).indexOf(password) === -1) assert(util.inspect(client, { depth }).indexOf(password) === -1) }) suite.test('Password should not exist in json.stringfy output', () => { - const pool = new helper.pg.Pool({ password }) - const client = new helper.pg.Client({ password }) + const pool = new helper.gaussdb.Pool({ password }) + const client = new helper.gaussdb.Client({ password }) assert(JSON.stringify(pool).indexOf(password) === -1) assert(JSON.stringify(client).indexOf(password) === -1) }) diff --git a/packages/gaussdb/test/integration/gh-issues/2079-tests.js b/packages/gaussdb/test/integration/gh-issues/2079-tests.js index 5c31b83d2..52e63f1b0 100644 --- a/packages/gaussdb/test/integration/gh-issues/2079-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2079-tests.js @@ -32,7 +32,7 @@ const makeTerminatingBackend = (byte) => { suite.test('SSL connection error allows event loop to exit', (done) => { const port = makeTerminatingBackend('N') - const client = new helper.pg.Client({ ssl: 'require', port, host: 'localhost' }) + const client = new helper.gaussdb.Client({ ssl: 'require', port, host: 'localhost' }) // since there was a connection error the client's socket should be closed // and the event loop will have no refs and exit cleanly client.connect((err) => { @@ -43,7 +43,7 @@ suite.test('SSL connection error allows event loop to exit', (done) => { suite.test('Non "S" response code allows event loop to exit', (done) => { const port = makeTerminatingBackend('X') - const client = new helper.pg.Client({ ssl: 'require', host: 'localhost', port }) + const client = new helper.gaussdb.Client({ ssl: 'require', host: 'localhost', port }) // since there was a connection error the client's socket should be closed // and the event loop will have no refs and exit cleanly client.connect((err) => { diff --git a/packages/gaussdb/test/integration/gh-issues/2085-tests.js b/packages/gaussdb/test/integration/gh-issues/2085-tests.js index d71c55c0d..8b4ad6a9e 100644 --- a/packages/gaussdb/test/integration/gh-issues/2085-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2085-tests.js @@ -16,7 +16,7 @@ suite.testAsync('it should connect over ssl', async () => { : { rejectUnauthorized: false, } - const client = new helper.pg.Client({ ssl }) + const client = new helper.gaussdb.Client({ ssl }) await client.connect() const { rows } = await client.query('SELECT NOW()') assert.strictEqual(rows.length, 1) @@ -25,7 +25,7 @@ suite.testAsync('it should connect over ssl', async () => { suite.testAsync('it should fail with self-signed cert error w/o rejectUnauthorized being passed', async () => { const ssl = helper.args.native ? 'verify-ca' : {} - const client = new helper.pg.Client({ ssl }) + const client = new helper.gaussdb.Client({ ssl }) try { await client.connect() } catch (e) { diff --git a/packages/gaussdb/test/integration/gh-issues/2108-tests.js b/packages/gaussdb/test/integration/gh-issues/2108-tests.js index 648b0df52..bdbde8394 100644 --- a/packages/gaussdb/test/integration/gh-issues/2108-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2108-tests.js @@ -3,11 +3,11 @@ const helper = require('./../test-helper') const suite = new helper.Suite() suite.test('Closing an unconnected client calls callback', (done) => { - const client = new helper.pg.Client() + const client = new helper.gaussdb.Client() client.end(done) }) suite.testAsync('Closing an unconnected client resolves promise', () => { - const client = new helper.pg.Client() + const client = new helper.gaussdb.Client() return client.end() }) diff --git a/packages/gaussdb/test/integration/gh-issues/2303-tests.js b/packages/gaussdb/test/integration/gh-issues/2303-tests.js index 533ae1645..e0a5acc31 100644 --- a/packages/gaussdb/test/integration/gh-issues/2303-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2303-tests.js @@ -8,30 +8,30 @@ const suite = new helper.Suite() const secret_value = 'FAIL THIS TEST' suite.test('SSL Key should not exist in toString() output', () => { - const pool = new helper.pg.Pool({ ssl: { key: secret_value } }) - const client = new helper.pg.Client({ ssl: { key: secret_value } }) + const pool = new helper.gaussdb.Pool({ ssl: { key: secret_value } }) + const client = new helper.gaussdb.Client({ ssl: { key: secret_value } }) assert(pool.toString().indexOf(secret_value) === -1) assert(client.toString().indexOf(secret_value) === -1) }) suite.test('SSL Key should not exist in util.inspect output', () => { - const pool = new helper.pg.Pool({ ssl: { key: secret_value } }) - const client = new helper.pg.Client({ ssl: { key: secret_value } }) + const pool = new helper.gaussdb.Pool({ ssl: { key: secret_value } }) + const client = new helper.gaussdb.Client({ ssl: { key: secret_value } }) const depth = 20 assert(util.inspect(pool, { depth }).indexOf(secret_value) === -1) assert(util.inspect(client, { depth }).indexOf(secret_value) === -1) }) suite.test('SSL Key should not exist in json.stringfy output', () => { - const pool = new helper.pg.Pool({ ssl: { key: secret_value } }) - const client = new helper.pg.Client({ ssl: { key: secret_value } }) + const pool = new helper.gaussdb.Pool({ ssl: { key: secret_value } }) + const client = new helper.gaussdb.Client({ ssl: { key: secret_value } }) assert(JSON.stringify(pool).indexOf(secret_value) === -1) assert(JSON.stringify(client).indexOf(secret_value) === -1) }) suite.test('SSL Key should exist for direct access', () => { - const pool = new helper.pg.Pool({ ssl: { key: secret_value } }) - const client = new helper.pg.Client({ ssl: { key: secret_value } }) + const pool = new helper.gaussdb.Pool({ ssl: { key: secret_value } }) + const client = new helper.gaussdb.Client({ ssl: { key: secret_value } }) assert(pool.options.ssl.key === secret_value) assert(client.connectionParameters.ssl.key === secret_value) }) @@ -39,8 +39,8 @@ suite.test('SSL Key should exist for direct access', () => { suite.test('SSL Key should exist for direct access even when non-enumerable custom config', () => { const config = { ssl: { key: secret_value } } Object.defineProperty(config.ssl, 'key', { enumerable: false }) - const pool = new helper.pg.Pool(config) - const client = new helper.pg.Client(config) + const pool = new helper.gaussdb.Pool(config) + const client = new helper.gaussdb.Client(config) assert(pool.options.ssl.key === secret_value) assert(client.connectionParameters.ssl.key === secret_value) }) diff --git a/packages/gaussdb/test/integration/gh-issues/2307-tests.js b/packages/gaussdb/test/integration/gh-issues/2307-tests.js index 240ac13f1..43c2dfd99 100644 --- a/packages/gaussdb/test/integration/gh-issues/2307-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2307-tests.js @@ -1,6 +1,6 @@ 'use strict' -const pg = require('../../../lib') +const gaussdb = require('../../../lib') const helper = require('../test-helper') const assert = require('assert') @@ -15,7 +15,7 @@ suite.test('bad ssl credentials do not cause crash', (done) => { }, } - const client = new pg.Client(config) + const client = new gaussdb.Client(config) client.connect((err) => { assert(err) diff --git a/packages/gaussdb/test/integration/gh-issues/2416-tests.js b/packages/gaussdb/test/integration/gh-issues/2416-tests.js index 1bb5aeff8..4cb6f60dd 100644 --- a/packages/gaussdb/test/integration/gh-issues/2416-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2416-tests.js @@ -4,7 +4,7 @@ const assert = require('assert') const suite = new helper.Suite() suite.testAsync('it sets search_path on connection', async () => { - const client = new helper.pg.Client({ + const client = new helper.gaussdb.Client({ options: '--search_path=foo', }) await client.connect() diff --git a/packages/gaussdb/test/integration/gh-issues/2627-tests.js b/packages/gaussdb/test/integration/gh-issues/2627-tests.js index 19f07f8af..ff0ec978a 100644 --- a/packages/gaussdb/test/integration/gh-issues/2627-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2627-tests.js @@ -28,7 +28,7 @@ const serverWithInvalidResponse = (port, callback) => { const server = net.createServer((socket) => { socket.write(MySqlHandshake) - // This server sends an invalid response which should throw in pg-protocol + // This server sends an invalid response which should throw in gaussdb-protocol sockets.add(socket) }) diff --git a/packages/gaussdb/test/integration/gh-issues/2716-tests.js b/packages/gaussdb/test/integration/gh-issues/2716-tests.js index 62d0942ba..89153a490 100644 --- a/packages/gaussdb/test/integration/gh-issues/2716-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/2716-tests.js @@ -5,7 +5,7 @@ const suite = new helper.Suite() // https://github.com/brianc/node-postgres/issues/2716 suite.testAsync('client.end() should resolve if already ended', async () => { - const client = new helper.pg.Client() + const client = new helper.gaussdb.Client() await client.connect() // this should resolve only when the underlying socket is fully closed, both diff --git a/packages/gaussdb/test/integration/gh-issues/3062-tests.js b/packages/gaussdb/test/integration/gh-issues/3062-tests.js index 325bcf9a4..3d9d79e81 100644 --- a/packages/gaussdb/test/integration/gh-issues/3062-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/3062-tests.js @@ -5,7 +5,7 @@ const suite = new helper.Suite() // https://github.com/brianc/node-postgres/issues/3062 suite.testAsync('result fields with the same name should pick the last value', async () => { - const client = new helper.pg.Client() + const client = new helper.gaussdb.Client() await client.connect() const { diff --git a/packages/gaussdb/test/integration/gh-issues/3174-tests.js b/packages/gaussdb/test/integration/gh-issues/3174-tests.js index 9949c8071..e48b69e54 100644 --- a/packages/gaussdb/test/integration/gh-issues/3174-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/3174-tests.js @@ -141,7 +141,7 @@ const testErrorBuffer = (bufferName, errorBuffer) => { const closeServer = await new Promise((resolve, reject) => { return startMockServer(options.port, errorBuffer, (closeServer) => resolve(closeServer)) }) - const pool = new helper.pg.Pool(options) + const pool = new helper.gaussdb.Pool(options) let errorHit = false pool.on('error', () => { diff --git a/packages/gaussdb/test/integration/gh-issues/507-tests.js b/packages/gaussdb/test/integration/gh-issues/507-tests.js index 1486bcd34..a78926e84 100644 --- a/packages/gaussdb/test/integration/gh-issues/507-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/507-tests.js @@ -1,10 +1,10 @@ 'use strict' const helper = require('../test-helper') -const pg = helper.pg +const gaussdb = helper.gaussdb const assert = require('assert') new helper.Suite().test('parsing array results', function (cb) { - const pool = new pg.Pool() + const pool = new gaussdb.Pool() pool.connect( assert.success(function (client, done) { client.query('CREATE TEMP TABLE test_table(bar integer, "baz\'s" integer)') diff --git a/packages/gaussdb/test/integration/gh-issues/675-tests.js b/packages/gaussdb/test/integration/gh-issues/675-tests.js index 8517fdbef..817684835 100644 --- a/packages/gaussdb/test/integration/gh-issues/675-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/675-tests.js @@ -2,7 +2,7 @@ const helper = require('../test-helper') const assert = require('assert') -const pool = new helper.pg.Pool() +const pool = new helper.gaussdb.Pool() pool.connect(function (err, client, done) { if (err) throw err diff --git a/packages/gaussdb/test/integration/gh-issues/699-tests.js b/packages/gaussdb/test/integration/gh-issues/699-tests.js index 7af83b8fd..47c2bf46e 100644 --- a/packages/gaussdb/test/integration/gh-issues/699-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/699-tests.js @@ -4,7 +4,7 @@ const copyFrom = require('pg-copy-streams').from if (helper.args.native) return -const pool = new helper.pg.Pool() +const pool = new helper.gaussdb.Pool() pool.connect(function (err, client, done) { if (err) throw err diff --git a/packages/gaussdb/test/integration/gh-issues/787-tests.js b/packages/gaussdb/test/integration/gh-issues/787-tests.js index 5d518475b..c497b9746 100644 --- a/packages/gaussdb/test/integration/gh-issues/787-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/787-tests.js @@ -1,6 +1,6 @@ 'use strict' const helper = require('../test-helper') -const pool = new helper.pg.Pool() +const pool = new helper.gaussdb.Pool() pool.connect(function (err, client) { const q = { diff --git a/packages/gaussdb/test/integration/gh-issues/981-tests.js b/packages/gaussdb/test/integration/gh-issues/981-tests.js index 68cfb0b1f..727f5250b 100644 --- a/packages/gaussdb/test/integration/gh-issues/981-tests.js +++ b/packages/gaussdb/test/integration/gh-issues/981-tests.js @@ -7,16 +7,16 @@ if (!helper.args.native) { } const assert = require('assert') -const pg = require('../../../lib') +const gaussdb = require('../../../lib') const native = require('../../../lib').native const JsClient = require('../../../lib/client') const NativeClient = require('../../../lib/native') -assert(pg.Client === JsClient) +assert(gaussdb.Client === JsClient) assert(native.Client === NativeClient) -const jsPool = new pg.Pool() +const jsPool = new gaussdb.Pool() const nativePool = new native.Pool() const suite = new helper.Suite() diff --git a/packages/gaussdb/test/integration/test-helper.js b/packages/gaussdb/test/integration/test-helper.js index 631acbae3..1fc89a27d 100644 --- a/packages/gaussdb/test/integration/test-helper.js +++ b/packages/gaussdb/test/integration/test-helper.js @@ -6,7 +6,7 @@ const assert = require('assert') if (helper.args.native) { Client = require('./../../lib/native') helper.Client = Client - helper.pg = helper.pg.native + helper.gaussdb = helper.gaussdb.native } // creates a client from cli parameters diff --git a/packages/gaussdb/test/test-helper.js b/packages/gaussdb/test/test-helper.js index da70973f6..38ac53c34 100644 --- a/packages/gaussdb/test/test-helper.js +++ b/packages/gaussdb/test/test-helper.js @@ -201,7 +201,7 @@ if (Object.isExtensible(assert)) { module.exports = { Suite: Suite, - pg: require('./../lib/'), + gaussdb: require('./../lib/'), args: args, config: args, sys: sys, diff --git a/packages/gaussdb/test/unit/client/configuration-tests.js b/packages/gaussdb/test/unit/client/configuration-tests.js index fa818121a..3f8e96737 100644 --- a/packages/gaussdb/test/unit/client/configuration-tests.js +++ b/packages/gaussdb/test/unit/client/configuration-tests.js @@ -5,22 +5,22 @@ const assert = require('assert') const suite = new helper.Suite() const test = suite.test.bind(suite) -const pguser = process.env['PGUSER'] || process.env.USER -const pgdatabase = process.env['PGDATABASE'] || process.env.USER -const pgport = process.env['PGPORT'] || 5432 +const gaussdbuser = process.env['PGUSER'] || process.env.USER +const gaussdbdatabase = process.env['PGDATABASE'] || process.env.USER +const gaussdbport = process.env['PGPORT'] || 5432 test('client settings', function () { test('defaults', function () { const client = new Client() - assert.equal(client.user, pguser) - assert.equal(client.database, pgdatabase) - assert.equal(client.port, pgport) + assert.equal(client.user, gaussdbuser) + assert.equal(client.database, gaussdbdatabase) + assert.equal(client.port, gaussdbport) assert.equal(client.ssl, false) }) test('custom', function () { const user = 'brian' - const database = 'pgjstest' + const database = 'gaussdbjstest' const password = 'boom' const client = new Client({ user: user, @@ -166,6 +166,6 @@ test('calls connect correctly on connection', function () { usedHost = host } client.connect() - assert.equal(usedPort, '/tmp/.s.PGSQL.' + pgport) + assert.equal(usedPort, '/tmp/.s.PGSQL.' + gaussdbport) assert.strictEqual(usedHost, undefined) }) diff --git a/packages/gaussdb/test/unit/client/early-disconnect-tests.js b/packages/gaussdb/test/unit/client/early-disconnect-tests.js index ae3470e88..e12172d30 100644 --- a/packages/gaussdb/test/unit/client/early-disconnect-tests.js +++ b/packages/gaussdb/test/unit/client/early-disconnect-tests.js @@ -1,7 +1,7 @@ 'use strict' require('./test-helper') const net = require('net') -const pg = require('../../../lib/index.js') +const gaussdb = require('../../../lib/index.js') const assert = require('assert') /* console.log() messages show up in `make test` output. TODO: fix it. */ @@ -11,7 +11,7 @@ const server = net.createServer(function (c) { }) server.listen(7777, function () { - const client = new pg.Client('gaussdb://localhost:7777') + const client = new gaussdb.Client('gaussdb://localhost:7777') client.connect( assert.calls(function (err) { assert(err) diff --git a/packages/gaussdb/test/unit/client/md5-password-tests.js b/packages/gaussdb/test/unit/client/md5-password-tests.js index 8fd2f7c2f..a242dda59 100644 --- a/packages/gaussdb/test/unit/client/md5-password-tests.js +++ b/packages/gaussdb/test/unit/client/md5-password-tests.js @@ -16,7 +16,7 @@ test('md5 authentication', async function () { test('responds', function () { assert.lengthIs(client.connection.stream.packets, 1) test('should have correct encrypted data', async function () { - const password = await crypto.postgresMd5PasswordHash(client.user, client.password, salt) + const password = await crypto.gaussdbMd5PasswordHash(client.user, client.password, salt) // how do we want to test this? assert.equalBuffers(client.connection.stream.packets[0], new BufferList().addCString(password).join(true, 'p')) }) diff --git a/packages/gaussdb/test/unit/client/set-keepalives-tests.js b/packages/gaussdb/test/unit/client/set-keepalives-tests.js index cae6846e3..4cc097689 100644 --- a/packages/gaussdb/test/unit/client/set-keepalives-tests.js +++ b/packages/gaussdb/test/unit/client/set-keepalives-tests.js @@ -1,6 +1,6 @@ 'use strict' const net = require('net') -const pg = require('../../../lib/index.js') +const gaussdb = require('../../../lib/index.js') const helper = require('./test-helper') const assert = require('assert') @@ -20,7 +20,7 @@ suite.test('setting keep alive', (done) => { done() } - const client = new pg.Client({ + const client = new gaussdb.Client({ host: 'localhost', port: 7777, keepAlive: true, diff --git a/packages/gaussdb/test/unit/client/sha256-password-tests.js b/packages/gaussdb/test/unit/client/sha256-password-tests.js index bf256c200..f95869fef 100644 --- a/packages/gaussdb/test/unit/client/sha256-password-tests.js +++ b/packages/gaussdb/test/unit/client/sha256-password-tests.js @@ -9,7 +9,7 @@ const test = suite.test.bind(suite) test('sha256 authentication', async function () { const client = helper.createClient() client.password = '!' - // Mock SHA256 authentication data following the format expected by postgresSha256PasswordHash, similar to the MD5 test + // Mock SHA256 authentication data following the format expected by gaussdbSha256PasswordHash, similar to the MD5 test // Structure: [4 bytes method][64 bytes random code][8 bytes token][4 bytes iteration] const data = Buffer.alloc(80) data.writeInt32BE(1, 0) // password method. in fact this data is not used in the hashing @@ -23,7 +23,7 @@ test('sha256 authentication', async function () { test('responds', function () { assert.lengthIs(client.connection.stream.packets, 1) test('should have correct encrypted data', async function () { - const hashedPassword = await crypto.postgresSha256PasswordHash(client.user, client.password, data) + const hashedPassword = await crypto.gaussdbSha256PasswordHash(client.user, client.password, data) assert.equalBuffers( client.connection.stream.packets[0], new BufferList().addCString(hashedPassword).join(true, 'p') @@ -48,7 +48,7 @@ test('sha256 authentication with empty password', async function () { test('responds with empty password', function () { assert.lengthIs(client.connection.stream.packets, 1) test('should have correct encrypted data for empty password', async function () { - const hashedPassword = await crypto.postgresSha256PasswordHash(client.user, client.password, data) + const hashedPassword = await crypto.gaussdbSha256PasswordHash(client.user, client.password, data) assert.equalBuffers( client.connection.stream.packets[0], new BufferList().addCString(hashedPassword).join(true, 'p') @@ -73,7 +73,7 @@ test('sha256 authentication with utf-8 password', async function () { test('responds with utf-8 password', function () { assert.lengthIs(client.connection.stream.packets, 1) test('should have correct encrypted data for utf-8 password', async function () { - const hashedPassword = await crypto.postgresSha256PasswordHash(client.user, client.password, data) + const hashedPassword = await crypto.gaussdbSha256PasswordHash(client.user, client.password, data) assert.equalBuffers( client.connection.stream.packets[0], new BufferList().addCString(hashedPassword).join(true, 'p') diff --git a/packages/gaussdb/test/unit/connection-parameters/creation-tests.js b/packages/gaussdb/test/unit/connection-parameters/creation-tests.js index b5ef7d077..c2c82ff33 100644 --- a/packages/gaussdb/test/unit/connection-parameters/creation-tests.js +++ b/packages/gaussdb/test/unit/connection-parameters/creation-tests.js @@ -348,10 +348,10 @@ suite.test('ssl is set on client', function () { defaults.ssl = true const c = new ConnectionParameters(sourceConfig) c.getLibpqConnectionString( - assert.calls(function (err, pgCString) { + assert.calls(function (err, gaussdbCString) { assert(!err) assert.equal( - pgCString.indexOf("sslrootcert='/path/root.crt'") !== -1, + gaussdbCString.indexOf("sslrootcert='/path/root.crt'") !== -1, true, 'libpqConnectionString should contain sslrootcert' ) diff --git a/packages/gaussdb/test/unit/connection-pool/configuration-tests.js b/packages/gaussdb/test/unit/connection-pool/configuration-tests.js index cfd8f0eec..f31dba6af 100644 --- a/packages/gaussdb/test/unit/connection-pool/configuration-tests.js +++ b/packages/gaussdb/test/unit/connection-pool/configuration-tests.js @@ -5,11 +5,11 @@ const helper = require('../test-helper') const suite = new helper.Suite() suite.test('pool with copied settings includes password', () => { - const original = new helper.pg.Pool({ + const original = new helper.gaussdb.Pool({ password: 'original', }) - const copy = new helper.pg.Pool(original.options) + const copy = new helper.gaussdb.Pool(original.options) assert.equal(copy.options.password, 'original') }) diff --git a/packages/gaussdb/test/unit/utils-tests.js b/packages/gaussdb/test/unit/utils-tests.js index 0e79e6265..fabe46398 100644 --- a/packages/gaussdb/test/unit/utils-tests.js +++ b/packages/gaussdb/test/unit/utils-tests.js @@ -7,10 +7,10 @@ const suite = new helper.Suite() const test = suite.test.bind(suite) test('ensure types is exported on root object', function () { - const pg = require('../../lib') - assert(pg.types) - assert(pg.types.getTypeParser) - assert(pg.types.setTypeParser) + const gaussdb = require('../../lib') + assert(gaussdb.types) + assert(gaussdb.types.getTypeParser) + assert(gaussdb.types.setTypeParser) }) test('normalizing query configs', function () { diff --git a/packages/pg-native/bench/index.js b/packages/pg-native/bench/index.js index e035c6c05..20c216871 100644 --- a/packages/pg-native/bench/index.js +++ b/packages/pg-native/bench/index.js @@ -1,4 +1,4 @@ -const pg = require('gaussdb').native +const gaussdb = require('gaussdb').native const Native = require('../') const warmup = function (fn, cb) { @@ -20,7 +20,7 @@ const native = Native() native.connectSync() const queryText = 'SELECT generate_series(0, 1000) as X, generate_series(0, 1000) as Y, generate_series(0, 1000) as Z' -const client = new pg.Client() +const client = new gaussdb.Client() client.connect(function () { const pure = function (cb) { client.query(queryText, function (err) {