Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only request returning attribute if client supports returning #1770

Merged
merged 3 commits into from
Feb 21, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import _ from 'lodash';
import Promise from './base/promise';

const supportsReturning = (client) => { return _.includes(['postgresql', 'oracle', 'mssql'], client) }

// Sync is the dispatcher for any database queries,
// taking the "syncing" `model` or `collection` being queried, along with
// a hash of options that are used in the various query methods.
Expand Down Expand Up @@ -192,7 +194,8 @@ _.extend(Sync.prototype, {
// Issues an `insert` command on the query - only used by models.
insert: Promise.method(function() {
const syncing = this.syncing;
return this.query.insert(syncing.format(_.extend(Object.create(null), syncing.attributes)), syncing.idAttribute);
return this.query.insert(syncing.format(_.extend(Object.create(null), syncing.attributes)),
supportsReturning(this.query.client.config.client) ? syncing.idAttribute : null);
}),

// Issues an `update` command on the query - only used by models.
Expand Down