Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
17 changes: 17 additions & 0 deletions lib/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -2182,3 +2182,20 @@ SQLConnector.prototype.discoverUniqueKeys = function(table, options, cb) {
const sql = self.buildQueryUniqueKeys(schema, table);
this.execute(sql, cb);
};

/**
* Discover if database is in strict mode
* @param {Function} [cb] The callback function
*/
SQLConnector.prototype.discoverIsStrict = function(cb) {
const self = this;
const sql = self.buildQueryIsStrict();
this.execute(sql, cb);
};

/**
* Build sql for checking if database is in strict mode
*/
SQLConnector.prototype.buildQueryIsStrict = function() {
throw new Error(g.f('{{isStrict}} must be implemented by the connector'));
};
4 changes: 4 additions & 0 deletions test/connectors/test-sql-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,7 @@ TestConnector.prototype.executeSQL = function(sql, params, options, callback) {
callback(null, result);
}
};

TestConnector.prototype.buildQueryIsStrict = function() {
return 'SELECT 1 AS globalStrictMode, 1 AS sessionStrictMode';
};
19 changes: 19 additions & 0 deletions test/sql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,4 +667,23 @@ describe('sql connector', function() {
});
});
});

it(
'should throw an error if buildQueryIsStrict is not implemented by SQLconnector',
function() {
const baseConnector = new SQLConnector();
expect(function() {
baseConnector.buildQueryIsStrict();
}).to.throw('isStrict must be implemented by the connector');
},
);

it('should support discoverIsStrict method', function(done) {
connector.discoverIsStrict(function(err, data) {
// eslint-disable-next-line no-unused-expressions
expect(err).to.be.null;
expect(data).to.be.an('array');
done(err);
});
});
});
Loading