Skip to content

Commit 54b0108

Browse files
committed
fix: squashed
1 parent a3cfe01 commit 54b0108

6 files changed

+76
-21
lines changed

CHANGES.md

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2024-01-10, Version 7.0.6
2+
=========================
3+
4+
* chore: update dependency loopback-datasource-juggler to ^5.0.5 (renovate[bot])
5+
6+
* chore: update dependency loopback-connector to ^6.1.1 (renovate[bot])
7+
8+
* chore: update dependency @commitlint/config-conventional to ^18.4.4 (renovate[bot])
9+
10+
* chore: update dependency eslint to ^8.56.0 (renovate[bot])
11+
12+
113
2023-12-07, Version 7.0.5
214
=========================
315

lib/discovery.js

+9
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,15 @@ function mixinDiscovery(MySQL, mysql) {
298298
return sql;
299299
};
300300

301+
/**
302+
* Build query to determine is strict mode
303+
*/
304+
305+
MySQL.prototype.buildQueryIsStrict = function() {
306+
return 'SELECT @@GLOBAL.sql_mode LIKE \'%STRICT%\' AS globalStrictMode,' +
307+
'@@SESSION.sql_mode LIKE \'%STRICT%\' AS sessionStrictMode;';
308+
};
309+
301310
/**
302311
* Discover foreign keys that reference to the primary key of this table
303312
* @param {String} table The table name

package-lock.json

+20-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "loopback-connector-mysql",
3-
"version": "7.0.5",
3+
"version": "7.0.6",
44
"description": "MySQL connector for loopback-datasource-juggler",
55
"engines": {
66
"node": ">=18"
@@ -24,16 +24,16 @@
2424
"async": "^3.2.5",
2525
"debug": "^4.3.4",
2626
"lodash": "^4.17.21",
27-
"loopback-connector": "^6.1.0",
27+
"loopback-connector": "^6.1.1",
2828
"mysql2": "^3.6.3",
2929
"patch-package": "^8.0.0",
3030
"strong-globalize": "^6.0.6"
3131
},
3232
"devDependencies": {
33-
"@commitlint/config-conventional": "^18.4.3",
33+
"@commitlint/config-conventional": "^18.4.4",
3434
"eslint": "^8.56.0",
3535
"eslint-config-loopback": "^13.1.0",
36-
"loopback-datasource-juggler": "^5.0.4",
36+
"loopback-datasource-juggler": "^5.0.5",
3737
"mocha": "^10.2.0",
3838
"rc": "^1.2.8",
3939
"should": "^13.2.3",

test/mysql.discover.test.js

+23
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
'use strict';
77
process.env.NODE_ENV = 'test';
88
const should = require('should');
9+
const async = require('async');
910

1011
const assert = require('assert');
1112
const DataSource = require('loopback-datasource-juggler').DataSource;
@@ -542,3 +543,25 @@ describe('Discover and build models', function() {
542543
});
543544
});
544545
});
546+
547+
describe('Discover schema with strict mode on', function() {
548+
let schema;
549+
before(function(done) {
550+
async.series([
551+
db.execute('SET GLOBAL sql_mode = \'STRICT_ALL_TABLES\';'),
552+
db.discoverSchema('INVENTORY', {owner: 'STRONGLOOP'}, function(err, schema_) {
553+
schema = schema_;
554+
done(err);
555+
}),
556+
]);
557+
});
558+
it('should return an LDL schema for INVENTORY with strict mode on', function() {
559+
assert.strictEqual(schema.name, 'Inventory');
560+
Object.keys(schema.properties).forEach(property => {
561+
if (schema.properties.length) {
562+
assert.strictEqual(property.jsonSchema.maxLength, property.length);
563+
}
564+
});
565+
async.series([db.execute('SET GLOBAL sql_mode = \'\';')]);
566+
});
567+
});

test/schema.sql

+8
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,11 @@ USE `STRONGLOOP`;
254254
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
255255

256256
-- Dump completed on 2016-08-09 19:14:01
257+
258+
--
259+
-- Current Database: `STRONGLOOP`
260+
--
261+
262+
/*!40000 DROP DATABASE IF EXISTS `STRONGLOOP-STRICT`*/;
263+
264+
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `STRONGLOOP-STRICT` /*!40100 DEFAULT CHARACTER SET utf8 */;

0 commit comments

Comments
 (0)