不要怂,就是干,撸起袖子干!

Commit a9730aa9 by Sushant Committed by GitHub

fix: pg@7 incompatibilities (#8979)

1 parent b545767f
...@@ -43,6 +43,7 @@ before_script: ...@@ -43,6 +43,7 @@ before_script:
- "if [ $POSTGRES_VER ]; then docker run --link ${POSTGRES_VER}:db -e CHECK_PORT=5432 -e CHECK_HOST=db --net sequelize_default giorgos/takis; fi" - "if [ $POSTGRES_VER ]; then docker run --link ${POSTGRES_VER}:db -e CHECK_PORT=5432 -e CHECK_HOST=db --net sequelize_default giorgos/takis; fi"
script: script:
- 'if [ "$INSTALL_MODULE" ]; then npm install ${INSTALL_MODULE}; fi'
- npm run lint - npm run lint
- "if [ $COVERAGE ]; then npm run cover && bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info; else npm run test; fi" - "if [ $COVERAGE ]; then npm run cover && bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info; else npm run test; fi"
...@@ -67,6 +68,10 @@ jobs: ...@@ -67,6 +68,10 @@ jobs:
node_js: '8' node_js: '8'
env: DIALECT=sqlite env: DIALECT=sqlite
- stage: test - stage: test
node_js: '4'
sudo: required
env: POSTGRES_VER=postgres-95 DIALECT=postgres COVERAGE=true INSTALL_MODULE="pg@6.x pg-native@1.x"
- stage: test
node_js: '6' node_js: '6'
env: DIALECT=sqlite env: DIALECT=sqlite
- stage: release - stage: release
......
...@@ -27,7 +27,7 @@ Sequelize is a promise-based Node.js ORM for Postgres, MySQL, SQLite and Microso ...@@ -27,7 +27,7 @@ Sequelize is a promise-based Node.js ORM for Postgres, MySQL, SQLite and Microso
$ npm install --save sequelize $ npm install --save sequelize
# And one of the following: # And one of the following:
$ npm install --save pg@6 pg-hstore # Note that `pg@7` is not supported yet $ npm install --save pg pg-hstore
$ npm install --save mysql2 $ npm install --save mysql2
$ npm install --save sqlite3 $ npm install --save sqlite3
$ npm install --save tedious # MSSQL $ npm install --save tedious # MSSQL
......
...@@ -202,8 +202,6 @@ const sequelize = new Sequelize('database', 'username', 'password', { ...@@ -202,8 +202,6 @@ const sequelize = new Sequelize('database', 'username', 'password', {
}) })
``` ```
**Note:** `pg@^7.0.0` is currently not supported.
### MSSQL ### MSSQL
The library for MSSQL is`tedious@^1.7.0` You'll just need to define the dialect: The library for MSSQL is`tedious@^1.7.0` You'll just need to define the dialect:
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
const stores = new Map(); const stores = new Map();
module.exports = dialect => { module.exports = dialect => {
if (!stores.has(dialect)) { if (!stores.has(dialect)) {
stores.set(dialect, new Map()); stores.set(dialect, new Map());
} }
......
...@@ -216,9 +216,9 @@ class ConnectionManager extends AbstractConnectionManager { ...@@ -216,9 +216,9 @@ class ConnectionManager extends AbstractConnectionManager {
type.types.postgres.oids.push(row.oid); type.types.postgres.oids.push(row.oid);
type.types.postgres.array_oids.push(row.typarray); type.types.postgres.array_oids.push(row.typarray);
this._refreshTypeParser(type);
} }
this.refreshTypeParser(dataTypes.postgres);
}); });
} }
} }
......
...@@ -95,8 +95,16 @@ class Query extends AbstractQuery { ...@@ -95,8 +95,16 @@ class Query extends AbstractQuery {
return queryResult; return queryResult;
}) })
.then(queryResult => { .then(queryResult => {
const rows = queryResult.rows; const rows = Array.isArray(queryResult)
const rowCount = queryResult.rowCount; ? queryResult.reduce((allRows, r) => allRows.concat(r.rows || []), [])
: queryResult.rows;
const rowCount = Array.isArray(queryResult)
? queryResult.reduce(
(count, r) => _.isFinite(r.rowCount) ? count + r.rowCount : count,
0
)
: queryResult.rowCount;
const isTableNameQuery = sql.indexOf('SELECT table_name FROM information_schema.tables') === 0; const isTableNameQuery = sql.indexOf('SELECT table_name FROM information_schema.tables') === 0;
const isRelNameQuery = sql.indexOf('SELECT relname FROM pg_class WHERE oid IN') === 0; const isRelNameQuery = sql.indexOf('SELECT relname FROM pg_class WHERE oid IN') === 0;
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
"lodash": "^4.17.1", "lodash": "^4.17.1",
"moment": "^2.13.0", "moment": "^2.13.0",
"moment-timezone": "^0.5.4", "moment-timezone": "^0.5.4",
"pg-types": "^1.13.0",
"retry-as-promised": "^2.3.1", "retry-as-promised": "^2.3.1",
"semver": "^5.5.0", "semver": "^5.5.0",
"terraformer-wkt-parser": "^1.1.2", "terraformer-wkt-parser": "^1.1.2",
...@@ -73,16 +74,16 @@ ...@@ -73,16 +74,16 @@
"istanbul": "^0.4.5", "istanbul": "^0.4.5",
"lcov-result-merger": "^2.0.0", "lcov-result-merger": "^2.0.0",
"mocha": "^5.0.0", "mocha": "^5.0.0",
"mysql2": "^1.5.1", "mysql2": "^1.x",
"pg": "^6.1.0", "pg": "^7.x",
"pg-hstore": "^2.3.2", "pg-hstore": "^2.3.2",
"pg-native": "^1.10.0", "pg-native": "^2.x",
"pg-types": "^1.11.0", "pg-types": "^1.x",
"rimraf": "^2.5.4", "rimraf": "^2.5.4",
"semantic-release": "^12.2.2", "semantic-release": "^12.2.2",
"sinon": "^4.2.2", "sinon": "^4.2.2",
"sinon-chai": "^2.14.0", "sinon-chai": "^2.14.0",
"sqlite3": "^3.1.13", "sqlite3": "^3.x",
"tedious": "1.14.0", "tedious": "1.14.0",
"uuid-validate": "^0.0.2", "uuid-validate": "^0.0.2",
"validate-commit-msg": "^2.12.2" "validate-commit-msg": "^2.12.2"
......
...@@ -18,7 +18,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => { ...@@ -18,7 +18,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), () => {
// Restore some sanity by resetting all parsers // Restore some sanity by resetting all parsers
switch (dialect) { switch (dialect) {
case 'postgres': case 'postgres':
const types = require('pg-types'); const types = this.sequelize.connectionManager.lib.types;
_.each(DataTypes, dataType => { _.each(DataTypes, dataType => {
if (dataType.types && dataType.types.postgres) { if (dataType.types && dataType.types.postgres) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!