mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-05 12:01:17 +01:00
PostgreSQL database driver (#5861)
* [test/database/list] Fix test list 4 being used in two different tests * [database/postgres] PostgreSQL database driver * [database/postgres] Make transactions work based on continuation scope. * [database/postgres] Implement nested transactions * eslint --fix * Add database changes from earlier this week to the PostgreSQL driver. * Fix typo * Fix postgres.incrObjectFieldBy returning undefined instead of null when given NaN * [database/postgres] Fix sortedSetsCard returning an array of strings. * Update socket.io postgres adapter * Fix PostgreSQL erroring when multiple updates are made to the same sorted set entry in a single operation. Add a test case to catch this error. * Fix lint errors. * Only prune sessions on one instance in a cluster to avoid deadlocks. They're caught and handled by the database server, but they spam the logs. * Fix arguments.slice.
This commit is contained in:
@@ -185,6 +185,8 @@ describe('Admin Controllers', function () {
|
||||
assert(body.redis);
|
||||
} else if (nconf.get('mongo')) {
|
||||
assert(body.mongo);
|
||||
} else if (nconf.get('postgres')) {
|
||||
assert(body.postgres);
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
@@ -48,6 +48,11 @@ describe('Test database', function () {
|
||||
assert.equal(err.message, 'The `mongodb` package is out-of-date, please run `./nodebb setup` again.');
|
||||
done();
|
||||
});
|
||||
} else if (dbName === 'postgres') {
|
||||
db.checkCompatibilityVersion('6.3.0', function (err) {
|
||||
assert.equal(err.message, 'The `pg` package is out-of-date, please run `./nodebb setup` again.');
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -111,16 +111,16 @@ describe('List methods', function () {
|
||||
before(function (done) {
|
||||
async.series([
|
||||
function (next) {
|
||||
db.listAppend('testList4', 12, next);
|
||||
db.listAppend('testList7', 12, next);
|
||||
},
|
||||
function (next) {
|
||||
db.listPrepend('testList4', 9, next);
|
||||
db.listPrepend('testList7', 9, next);
|
||||
},
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should remove the last element of list and return it', function (done) {
|
||||
db.listRemoveLast('testList4', function (err, lastElement) {
|
||||
db.listRemoveLast('testList7', function (err, lastElement) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(arguments.length, 2);
|
||||
assert.equal(lastElement, '12');
|
||||
|
||||
@@ -42,6 +42,21 @@ describe('Sorted Set methods', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should gracefully handle adding the same element twice', function (done) {
|
||||
db.sortedSetAdd('sorted2', [1, 2], ['value1', 'value1'], function (err) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(arguments.length, 1);
|
||||
|
||||
db.sortedSetScore('sorted2', 'value1', function (err, score) {
|
||||
assert.equal(err, null);
|
||||
assert.equal(score, 2);
|
||||
assert.equal(arguments.length, 2);
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('sortedSetsAdd()', function () {
|
||||
|
||||
@@ -59,6 +59,14 @@ if (!testDbConfig) {
|
||||
' "password": "",\n' +
|
||||
' "database": "nodebb_test"\n' +
|
||||
'}\n' +
|
||||
' or (postgres):\n' +
|
||||
'"test_database": {\n' +
|
||||
' "host": "127.0.0.1",\n' +
|
||||
' "port": "5432",\n' +
|
||||
' "username": "postgres",\n' +
|
||||
' "password": "",\n' +
|
||||
' "database": "nodebb_test"\n' +
|
||||
'}\n' +
|
||||
'==========================================================='
|
||||
);
|
||||
winston.error(errorText);
|
||||
|
||||
Reference in New Issue
Block a user