mirror of
https://github.com/knex/knex.git
synced 2025-12-27 06:58:39 +00:00
Explicit jsonb support for custom pg clients (#5201)
Co-authored-by: Igor Savin <iselwin@gmail.com>
This commit is contained in:
parent
1cc1df9c35
commit
97fccdff7d
@ -145,6 +145,7 @@ function jsonColumn(client, jsonb) {
|
||||
if (
|
||||
!client.version ||
|
||||
client.config.client === 'cockroachdb' ||
|
||||
client.config.jsonbSupport === true ||
|
||||
parseFloat(client.version) >= 9.2
|
||||
) {
|
||||
return jsonb ? 'jsonb' : 'json';
|
||||
|
||||
@ -93,6 +93,41 @@ describe('PostgreSQL Config', function () {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('check custom pg client', function () {
|
||||
it('jsonb as text', function () {
|
||||
knexInstance = knex({
|
||||
...config,
|
||||
version: 'custom-pg',
|
||||
jsonbSupport: false,
|
||||
});
|
||||
tableSql = knexInstance.schema
|
||||
.table('public', function (t) {
|
||||
t.jsonb('test_name');
|
||||
})
|
||||
.toSQL();
|
||||
equal(1, tableSql.length);
|
||||
expect(tableSql[0].sql).to.equal(
|
||||
'alter table "public" add column "test_name" text'
|
||||
);
|
||||
});
|
||||
it('jsonb', function () {
|
||||
knexInstance = knex({
|
||||
...config,
|
||||
version: 'custom-pg',
|
||||
jsonbSupport: true,
|
||||
});
|
||||
tableSql = knexInstance.schema
|
||||
.table('public', function (t) {
|
||||
t.jsonb('test_name');
|
||||
})
|
||||
.toSQL();
|
||||
equal(1, tableSql.length);
|
||||
expect(tableSql[0].sql).to.equal(
|
||||
'alter table "public" add column "test_name" jsonb'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
1
types/index.d.ts
vendored
1
types/index.d.ts
vendored
@ -2699,6 +2699,7 @@ export declare namespace Knex {
|
||||
debug?: boolean;
|
||||
client?: string | typeof Client;
|
||||
dialect?: string;
|
||||
jsonbSupport?: boolean;
|
||||
version?: string;
|
||||
connection?: string | StaticConnectionConfig | ConnectionConfigProvider;
|
||||
pool?: PoolConfig;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user