Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions packages/gaussdb-cursor/test/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ const assert = require('assert')
const Cursor = require('../')
const gaussdb = require('gaussdb-node')

// 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', () => {
describe('transactions', () => {
it('can execute multiple statements in a transaction', async () => {
const client = new gaussdb.Client()
await client.connect()
await client.query('begin')
await client.query('CREATE TEMP TABLE foobar(id SERIAL PRIMARY KEY)')
await client.query('CREATE TEMP TABLE foobar(id INTEGER PRIMARY KEY)')
const cursor = client.query(new Cursor('SELECT * FROM foobar'))
const rows = await new Promise((resolve, reject) => {
cursor.read(10, (err, rows) => (err ? reject(err) : resolve(rows)))
Expand All @@ -23,7 +21,7 @@ describe.skip('transactions', () => {
const client = new gaussdb.Client()
await client.connect()
await client.query('begin')
await client.query('CREATE TEMP TABLE foobar(id SERIAL PRIMARY KEY)')
await client.query('CREATE TEMP TABLE foobar(id INTEGER PRIMARY KEY)')
const cursor = client.query(new Cursor('SELECT * FROM foobar'))
await new Promise((resolve) => cursor.close(resolve))
await client.query('ALTER TABLE foobar ADD COLUMN name TEXT')
Expand All @@ -35,7 +33,7 @@ describe.skip('transactions', () => {
await client.connect()
await client.query('begin')
// create a cursor that has no data response
const createText = 'CREATE TEMP TABLE foobar(id SERIAL PRIMARY KEY)'
const createText = 'CREATE TEMP TABLE foobar(id INTEGER PRIMARY KEY)'
const cursor = client.query(new Cursor(createText))
const err = await new Promise((resolve) => cursor.read(100, resolve))
assert.ifError(err)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,57 @@
'use strict'
// const helper = require('./test-helper')
// const assert = require('assert')

// SKIP: 不支持 临时表Serial
// 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.gaussdb.Pool()
pool.connect(
assert.success(function (client, done) {
helper.versionGTE(
client,
90200,
assert.success(function (jsonSupported) {
if (!jsonSupported) {
console.log('skip json test on older versions of postgres')
done()
return pool.end()
const helper = require('./test-helper')
const suite = new helper.Suite()
const assert = require('assert')

suite.test('json type parsing', function (done) {
const client = helper.client()

// Check if JSON is supported
client.query('SHOW server_version_num', function (err, versionResult) {
if (err) {
done(err)
return
}

const versionNum = parseInt(versionResult.rows[0].server_version_num)
if (versionNum < 90200) {
console.log('skip json test on older versions of postgres')
client.end()
done()
return
}

client.query('CREATE TEMP TABLE stuff(id INTEGER PRIMARY KEY, data JSON)', function (err) {
if (err) {
done(err)
return
}

const value = { name: 'Brian', age: 250, alive: true, now: new Date() }
client.query('INSERT INTO stuff (id, data) VALUES (1, $1)', [value], function (err) {
if (err) {
done(err)
return
}
client.query('CREATE TEMP TABLE stuff(id SERIAL PRIMARY KEY, data JSON)')
const value = { name: 'Brian', age: 250, alive: true, now: new Date() }
client.query('INSERT INTO stuff (data) VALUES ($1)', [value])
client.query(
'SELECT * FROM stuff',
assert.success(function (result) {
assert.equal(result.rows.length, 1)
assert.equal(typeof result.rows[0].data, 'object')
const row = result.rows[0].data
assert.strictEqual(row.name, value.name)
assert.strictEqual(row.age, value.age)
assert.strictEqual(row.alive, value.alive)
assert.equal(JSON.stringify(row.now), JSON.stringify(value.now))
done()
pool.end()
})
)

client.query('SELECT * FROM stuff', function (err, result) {
if (err) {
done(err)
return
}

assert.equal(result.rows.length, 1)
assert.equal(typeof result.rows[0].data, 'object')
const row = result.rows[0].data
assert.strictEqual(row.name, value.name)
assert.strictEqual(row.age, value.age)
assert.strictEqual(row.alive, value.alive)
assert.equal(JSON.stringify(row.now), JSON.stringify(value.now))

client.end()
done()
})
})
)
})
})
)
*/
})
18 changes: 7 additions & 11 deletions packages/gaussdb-node/test/integration/client/no-data-tests.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
'use strict'
// const helper = require('./test-helper')
// const suite = new helper.Suite()
// const assert = require('assert')
const helper = require('./test-helper')
const suite = new helper.Suite()
const assert = require('assert')

// SKIP: 不支持 临时表Serial
// 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

/*
suite.test('noData message handling', function () {
const client = helper.client()

client.query({
name: 'boom',
text: 'create temp table boom(id serial, size integer)',
text: 'create temp table boom(id integer primary key, size integer)',
})

client.query(
{
name: 'insert',
text: 'insert into boom(size) values($1)',
text: 'insert into boom(id, size) values(1, $1)',
values: [100],
},
function (err, result) {
Expand All @@ -30,7 +26,8 @@ suite.test('noData message handling', function () {
)

client.query({
name: 'insert',
name: 'insert-2',
text: 'insert into boom(id, size) values(2, $1)',
values: [101],
})

Expand All @@ -48,4 +45,3 @@ suite.test('noData message handling', function () {

client.on('drain', client.end.bind(client))
})
*/
15 changes: 5 additions & 10 deletions packages/gaussdb-node/test/integration/client/parse-int-8-tests.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
'use strict'

// const helper = require('../test-helper')
// const gaussdb = helper.gaussdb
// const suite = new helper.Suite()
// const assert = require('assert')
const helper = require('../test-helper')
const gaussdb = helper.gaussdb
const suite = new helper.Suite()
const assert = require('assert')

// SKIP: 不支持 临时表Serial
// 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 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) {
gaussdb.defaults.parseInt8 = true
client.query('CREATE TEMP TABLE asdf(id SERIAL PRIMARY KEY)')
client.query('CREATE TEMP TABLE asdf(id INTEGER PRIMARY KEY)')
client.query(
'SELECT COUNT(*) as "count", \'{1,2,3}\'::bigint[] as array FROM asdf',
assert.success(function (res) {
Expand All @@ -40,4 +36,3 @@ suite.test('ability to turn on and off parser', function () {
})
)
})
*/
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@ test('prepared statements do not mutate params', function () {
})
})

// SKIP: 不支持 临时表Serial
// 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

/*
test('multiple simple queries', function () {
const client = helper.client()
client.query({ text: "create temp table bang(id serial, name varchar(5));insert into bang(name) VALUES('boom');" })
client.query("insert into bang(name) VALUES ('yes');")
client.query({
text: "create temp table bang(id integer, name varchar(5));insert into bang(id, name) VALUES(1, 'boom');",
})
client.query("insert into bang(id, name) VALUES (2, 'yes');")
const query = client.query(new Query('select name from bang'))
assert.emits(query, 'row', function (row) {
assert.equal(row['name'], 'boom')
Expand All @@ -84,7 +82,6 @@ test('multiple simple queries', function () {
})
client.on('drain', client.end.bind(client))
})
*/

test('multiple select statements', function () {
const client = helper.client()
Expand Down
15 changes: 6 additions & 9 deletions packages/gaussdb-node/test/integration/gh-issues/1105-tests.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
// const helper = require('../test-helper')
// const suite = new helper.Suite()
const helper = require('../test-helper')
const suite = new helper.Suite()

// SKIP: 不支持 临时表Serial
// 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

/*
suite.testAsync('timeout causing query crashes', async () => {
const client = new helper.Client()
await client.connect()
await client.query('CREATE TEMP TABLE foobar( name TEXT NOT NULL, id SERIAL)')
await client.query('CREATE TEMP TABLE foobar( name TEXT NOT NULL, id INTEGER PRIMARY KEY)')
await client.query('BEGIN')
await client.query("SET LOCAL statement_timeout TO '1ms'")
let count = 0
let idCounter = 1
while (count++ < 5000) {
try {
await client.query('INSERT INTO foobar(name) VALUES ($1)', [Math.random() * 1000 + ''])
await client.query('INSERT INTO foobar(id, name) VALUES ($1, $2)', [idCounter++, Math.random() * 1000 + ''])
} catch (e) {
await client.query('ROLLBACK')
break
}
}
await client.end()
})
*/
7 changes: 4 additions & 3 deletions packages/gaussdb-query-stream/test/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ helper('error', function (client) {
})
})

// 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('error recovery', () => {
// created from https://github.com/chrisdickinson/pg-test-case
it('recovers from a streaming error in a transaction', async () => {
Expand All @@ -35,7 +33,10 @@ describe('error recovery', () => {
updated timestamp
)`)
await client.query(`BEGIN;`)
const query = new QueryStream(`INSERT INTO frobnicators (id, updated) VALUES ($1, $2) RETURNING "id"`, [1, Date.now()])
const query = new QueryStream(`INSERT INTO frobnicators (id, updated) VALUES ($1, $2) RETURNING "id"`, [
1,
Date.now(),
])
let error: Error | undefined = undefined
query.on('data', console.log).on('error', (e) => {
error = e
Expand Down