Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad committed Aug 31, 2022
2 parents 05c4707 + 13b61c0 commit f52b2c5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 9 deletions.
1 change: 1 addition & 0 deletions lib/dialects/postgres/schema/pg-columncompiler.js
Expand Up @@ -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';
Expand Down
18 changes: 9 additions & 9 deletions package.json
Expand Up @@ -105,8 +105,8 @@
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.1",
"@types/node": "^18.0.4",
"better-sqlite3": "^7.5.1",
"@types/node": "^18.7.14",
"better-sqlite3": "^7.6.2",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"chai-subset-in-order": "^3.1.0",
Expand All @@ -123,24 +123,24 @@
"JSONStream": "^1.3.5",
"lint-staged": "^13.0.0",
"mocha": "^10.0.0",
"mock-fs": "^5.1.2",
"mock-fs": "^5.1.4",
"mysql": "^2.18.1",
"mysql2": "^2.3.3",
"nyc": "^15.1.0",
"oracledb": "^5.3.0",
"pg": "^8.7.3",
"pg-query-stream": "^4.2.1",
"oracledb": "^5.4.0",
"pg": "^8.8.0",
"pg-query-stream": "^4.2.4",
"prettier": "2.6.2",
"rimraf": "^3.0.2",
"sinon": "^14.0.0",
"sinon-chai": "^3.7.0",
"source-map-support": "^0.5.21",
"sqlite3": "^5.0.4",
"sqlite3": "^5.0.11",
"tap-spec": "^5.0.0",
"tape": "^5.5.3",
"tape": "^5.6.0",
"tedious": "^14.4.0",
"toxiproxy-node-client": "^2.0.6",
"ts-node": "^10.7.0",
"ts-node": "^10.9.1",
"tsd": "^0.23.0",
"typescript": "4.8.2"
},
Expand Down
35 changes: 35 additions & 0 deletions test/unit/schema-builder/postgres.js
Expand Up @@ -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'
);
});
});
});
});

Expand Down
1 change: 1 addition & 0 deletions types/index.d.ts
Expand Up @@ -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;
Expand Down

0 comments on commit f52b2c5

Please sign in to comment.