Skip to content

Commit

Permalink
fix: squashed
Browse files Browse the repository at this point in the history
  • Loading branch information
aaqilniz committed Apr 14, 2024
1 parent a3cfe01 commit 54b0108
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 21 deletions.
12 changes: 12 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
2024-01-10, Version 7.0.6
=========================

* chore: update dependency loopback-datasource-juggler to ^5.0.5 (renovate[bot])

* chore: update dependency loopback-connector to ^6.1.1 (renovate[bot])

* chore: update dependency @commitlint/config-conventional to ^18.4.4 (renovate[bot])

* chore: update dependency eslint to ^8.56.0 (renovate[bot])


2023-12-07, Version 7.0.5
=========================

Expand Down
9 changes: 9 additions & 0 deletions lib/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,15 @@ function mixinDiscovery(MySQL, mysql) {
return sql;
};

/**
* Build query to determine is strict mode
*/

MySQL.prototype.buildQueryIsStrict = function() {
return 'SELECT @@GLOBAL.sql_mode LIKE \'%STRICT%\' AS globalStrictMode,' +
'@@SESSION.sql_mode LIKE \'%STRICT%\' AS sessionStrictMode;';
};

/**
* Discover foreign keys that reference to the primary key of this table
* @param {String} table The table name
Expand Down
37 changes: 20 additions & 17 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loopback-connector-mysql",
"version": "7.0.5",
"version": "7.0.6",
"description": "MySQL connector for loopback-datasource-juggler",
"engines": {
"node": ">=18"
Expand All @@ -24,16 +24,16 @@
"async": "^3.2.5",
"debug": "^4.3.4",
"lodash": "^4.17.21",
"loopback-connector": "^6.1.0",
"loopback-connector": "^6.1.1",
"mysql2": "^3.6.3",
"patch-package": "^8.0.0",
"strong-globalize": "^6.0.6"
},
"devDependencies": {
"@commitlint/config-conventional": "^18.4.3",
"@commitlint/config-conventional": "^18.4.4",
"eslint": "^8.56.0",
"eslint-config-loopback": "^13.1.0",
"loopback-datasource-juggler": "^5.0.4",
"loopback-datasource-juggler": "^5.0.5",
"mocha": "^10.2.0",
"rc": "^1.2.8",
"should": "^13.2.3",
Expand Down
23 changes: 23 additions & 0 deletions test/mysql.discover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
'use strict';
process.env.NODE_ENV = 'test';
const should = require('should');
const async = require('async');

const assert = require('assert');
const DataSource = require('loopback-datasource-juggler').DataSource;
Expand Down Expand Up @@ -542,3 +543,25 @@ describe('Discover and build models', function() {
});
});
});

describe('Discover schema with strict mode on', function() {
let schema;
before(function(done) {
async.series([
db.execute('SET GLOBAL sql_mode = \'STRICT_ALL_TABLES\';'),
db.discoverSchema('INVENTORY', {owner: 'STRONGLOOP'}, function(err, schema_) {
schema = schema_;
done(err);
}),
]);
});
it('should return an LDL schema for INVENTORY with strict mode on', function() {
assert.strictEqual(schema.name, 'Inventory');
Object.keys(schema.properties).forEach(property => {
if (schema.properties.length) {
assert.strictEqual(property.jsonSchema.maxLength, property.length);
}
});
async.series([db.execute('SET GLOBAL sql_mode = \'\';')]);
});
});
8 changes: 8 additions & 0 deletions test/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,11 @@ USE `STRONGLOOP`;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2016-08-09 19:14:01

--
-- Current Database: `STRONGLOOP`
--

/*!40000 DROP DATABASE IF EXISTS `STRONGLOOP-STRICT`*/;

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `STRONGLOOP-STRICT` /*!40100 DEFAULT CHARACTER SET utf8 */;

0 comments on commit 54b0108

Please sign in to comment.