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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/postgresql.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ PostgreSQL.prototype.getDefaultSchemaName = function() {
return 'public';
};

PostgreSQL.prototype.multiInsertSupported = true;

/**
* Connect to PostgreSQL
* @callback {Function} [callback] The callback after the connection is established
Expand Down Expand Up @@ -591,6 +593,15 @@ PostgreSQL.prototype.getInsertedId = function(model, info) {
return idValue;
};

PostgreSQL.prototype.getInsertedIds = function(model, info) {
const idColName = this.idColumn(model);
let idValues;
if (info && Array.isArray(info)) {
idValues = info.map((data) => data[idColName]);
}
return idValues;
};

/**
* Build the SQL WHERE clause for the where object
* @param {string} model Model name
Expand Down
113 changes: 76 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "IBM Corp.",
"repository": "github:loopbackio/loopback-connector-postgresql",
"engines": {
"node": ">=10"
"node": "14 || 16 || 18"
},
"scripts": {
"pretest": "node pretest.js",
Expand All @@ -33,7 +33,7 @@
"bluebird": "^3.4.6",
"chalk": "^4.0.0",
"debug": "^4.1.1",
"loopback-connector": "^5.0.0",
"loopback-connector": "^5.1.1",
"pg": "^8.0.2",
"strong-globalize": "^6.0.0",
"uuid": "^9.0.0"
Expand All @@ -46,7 +46,7 @@
"juggler-v3": "file:./deps/juggler-v3",
"juggler-v4": "file:./deps/juggler-v4",
"lodash": "^4.17.4",
"loopback-datasource-juggler": "^3.0.0 || ^4.0.0",
"loopback-datasource-juggler": "^4.28.0",
Copy link
Member

@dhmlau dhmlau Nov 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change, though loopback-datasource-juggle@3.x reaches EOL. Together with the discussion in #520, it might be a good time to do it.

@loopbackio/loopback-maintainers, thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes its a breaking change. So I agree to go ahead with it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for making a breaking change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"mocha": "^10.0.0",
"rc": "^1.0.0",
"should": "^13.2.3",
Expand Down
5 changes: 4 additions & 1 deletion pretest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ process.env.PGPASSWORD = process.env.TEST_POSTGRESQL_PASSWORD ||
process.env.POSTGRESQL_PASSWORD || process.env.PGPASSWORD || 'test';

console.log('seeding DB with test db...');
const psql = cp.spawn('psql', {stdio: stdio});
const args = process.env.POSTGRESQL_DATABASE ?
['-U', process.env.PGUSER, process.env.POSTGRESQL_DATABASE] :
['-U', process.env.PGUSER];
const psql = cp.spawn('psql', args, {stdio: stdio});
sql.pipe(psql.stdin);
psql.on('exit', function(code) {
console.log('done seeding DB');
Expand Down
Loading