Compare commits
No commits in common. "master" and "v7.0.12" have entirely different histories.
|
@ -8,7 +8,7 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-22.04
|
||||||
env:
|
env:
|
||||||
MYSQL_HOST: '127.0.0.1'
|
MYSQL_HOST: '127.0.0.1'
|
||||||
MYSQL_USER: myUser
|
MYSQL_USER: myUser
|
||||||
|
|
102
CHANGES.md
102
CHANGES.md
|
@ -1,105 +1,3 @@
|
||||||
2025-03-18, Version 7.1.1
|
|
||||||
=========================
|
|
||||||
|
|
||||||
* chore: update dependency loopback-datasource-juggler to ^5.1.6 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency loopback-connector to ^6.2.2 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency @commitlint/config-conventional to ^19.8.0 (renovate[bot])
|
|
||||||
|
|
||||||
|
|
||||||
2025-02-12, Version 7.1.0
|
|
||||||
=========================
|
|
||||||
|
|
||||||
* chore: update dependency loopback-datasource-juggler to ^5.1.5 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency loopback-connector to ^6.2.1 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency @commitlint/config-conventional to ^19.7.1 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency loopback-connector to ^6.2.0 (renovate[bot])
|
|
||||||
|
|
||||||
* feat: query to fetch unique columns (Muhammad Aaqil)
|
|
||||||
|
|
||||||
* chore: update dependency mocha to ^11.1.0 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency debug to ^4.4.0 (renovate[bot])
|
|
||||||
|
|
||||||
|
|
||||||
2024-12-05, Version 7.0.17
|
|
||||||
==========================
|
|
||||||
|
|
||||||
* chore: update dependency loopback-datasource-juggler to ^5.1.3 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency loopback-connector to ^6.1.12 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency mocha to v11 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency @commitlint/config-conventional to ^19.6.0 (renovate[bot])
|
|
||||||
|
|
||||||
|
|
||||||
2024-11-12, Version 7.0.16
|
|
||||||
==========================
|
|
||||||
|
|
||||||
* chore: update dependency loopback-connector to ^6.1.11 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency loopback-datasource-juggler to ^5.1.2 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency mocha to ^10.8.2 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency loopback-connector to ^6.1.10 (renovate[bot])
|
|
||||||
|
|
||||||
|
|
||||||
2024-10-11, Version 7.0.15
|
|
||||||
==========================
|
|
||||||
|
|
||||||
* chore: update dependency loopback-datasource-juggler to ^5.1.1 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency sinon to v19 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency ubuntu to v24 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency eslint to ^8.57.1 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency sinon to ^18.0.1 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency @commitlint/config-conventional to ^19.5.0 (renovate[bot])
|
|
||||||
|
|
||||||
|
|
||||||
2024-09-09, Version 7.0.14
|
|
||||||
==========================
|
|
||||||
|
|
||||||
* chore: update dependency loopback-datasource-juggler to ^5.1.0 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency loopback-connector to ^6.1.9 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency debug to ^4.3.7 (renovate[bot])
|
|
||||||
|
|
||||||
* fix: enable migration for enum property (Muhammad Aaqil)
|
|
||||||
|
|
||||||
* fix: change condition to treat tinyint as boolean (Muhammad Aaqil)
|
|
||||||
|
|
||||||
* chore: update dependency async to ^3.2.6 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency @commitlint/config-conventional to ^19.4.1 (renovate[bot])
|
|
||||||
|
|
||||||
* fix: mark primary key auto-increment only if column type is TINYINT SMALLINT MEDIUMINT INT BIGINT (Muhammad Aaqil)
|
|
||||||
|
|
||||||
* chore: update dependency loopback-connector to ^6.1.8 (renovate[bot])
|
|
||||||
|
|
||||||
|
|
||||||
2024-08-12, Version 7.0.13
|
|
||||||
==========================
|
|
||||||
|
|
||||||
* chore: update dependency loopback-datasource-juggler to ^5.0.12 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency mocha to ^10.7.3 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency debug to ^4.3.6 (renovate[bot])
|
|
||||||
|
|
||||||
* chore: update dependency mocha to ^10.7.0 (renovate[bot])
|
|
||||||
|
|
||||||
|
|
||||||
2024-07-04, Version 7.0.12
|
2024-07-04, Version 7.0.12
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
|
|
@ -301,29 +301,6 @@ function mixinDiscovery(MySQL, mysql) {
|
||||||
return sql;
|
return sql;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Discover unique keys for a given table
|
|
||||||
* @param {String} table The table name
|
|
||||||
* @param {Object} options The options for discovery
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* Retrieves a list of column names that have unique key index
|
|
||||||
* @param schema
|
|
||||||
* @param table
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
MySQL.prototype.buildQueryUniqueKeys = function(schema, table) {
|
|
||||||
const sql = 'SELECT Column_name AS "columnName",' +
|
|
||||||
' table_schema AS "owner",' +
|
|
||||||
' table_name AS "tableName"' +
|
|
||||||
' FROM Information_schema.statistics' +
|
|
||||||
' WHERE Table_schema = ' + mysql.escape(schema) +
|
|
||||||
' AND Table_name = ' + mysql.escape(table) +
|
|
||||||
' AND Non_unique = 0 AND Index_name <> \'PRIMARY\';';
|
|
||||||
return sql;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discover foreign keys that reference to the primary key of this table
|
* Discover foreign keys that reference to the primary key of this table
|
||||||
* @param {String} table The table name
|
* @param {String} table The table name
|
||||||
|
@ -381,8 +358,8 @@ function mixinDiscovery(MySQL, mysql) {
|
||||||
}
|
}
|
||||||
return 'Binary';
|
return 'Binary';
|
||||||
case 'TINYINT':
|
case 'TINYINT':
|
||||||
// treat TINYINT as boolean as it is aliased as BOOL and BOOLEAN in mysql
|
// treat TINYINT(1) as boolean as it is aliased as BOOL and BOOLEAN in mysql
|
||||||
if (!options.treatTINYINT1AsTinyInt && columnType.includes('tinyint')) {
|
if (!options.treatTINYINT1AsTinyInt && columnType === 'tinyint(1)') {
|
||||||
return 'Boolean';
|
return 'Boolean';
|
||||||
}
|
}
|
||||||
case 'SMALLINT':
|
case 'SMALLINT':
|
||||||
|
|
|
@ -628,13 +628,7 @@ function mixinMigration(MySQL, mysql) {
|
||||||
if (pks.length === 1) {
|
if (pks.length === 1) {
|
||||||
const idName = this.idName(model);
|
const idName = this.idName(model);
|
||||||
const idProp = this.getModelDefinition(model).properties[idName];
|
const idProp = this.getModelDefinition(model).properties[idName];
|
||||||
const idColumnType = this.columnDataType(model, idName);
|
if (idProp.generated) {
|
||||||
if (idProp.generated && (
|
|
||||||
idColumnType === 'TINYINT' ||
|
|
||||||
idColumnType === 'SMALLINT' ||
|
|
||||||
idColumnType === 'MEDIUMINT' ||
|
|
||||||
idColumnType === 'INT' ||
|
|
||||||
idColumnType === 'BIGINT')) {
|
|
||||||
sql.push(self.columnEscaped(model, idName) + ' ' +
|
sql.push(self.columnEscaped(model, idName) + ' ' +
|
||||||
self.buildColumnDefinition(model, idName) + ' AUTO_INCREMENT PRIMARY KEY');
|
self.buildColumnDefinition(model, idName) + ' AUTO_INCREMENT PRIMARY KEY');
|
||||||
} else {
|
} else {
|
||||||
|
@ -770,21 +764,10 @@ function mixinMigration(MySQL, mysql) {
|
||||||
const colLength = columnMetadata && columnMetadata.dataLength || prop.length || prop.limit;
|
const colLength = columnMetadata && columnMetadata.dataLength || prop.length || prop.limit;
|
||||||
const colPrecision = columnMetadata && columnMetadata.dataPrecision;
|
const colPrecision = columnMetadata && columnMetadata.dataPrecision;
|
||||||
const colScale = columnMetadata && columnMetadata.dataScale;
|
const colScale = columnMetadata && columnMetadata.dataScale;
|
||||||
let enumList = '';
|
|
||||||
if (colType && colType === 'ENUM') {
|
|
||||||
if (prop.jsonSchema && prop.jsonSchema.enum) {
|
|
||||||
prop.jsonSchema.enum.forEach(item => {
|
|
||||||
enumList += `'${item}',`;
|
|
||||||
});
|
|
||||||
// remove trailing comma
|
|
||||||
enumList = enumList.substring(0, enumList.length - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// info on setting column specific properties
|
// info on setting column specific properties
|
||||||
// i.e dataLength, dataPrecision, dataScale
|
// i.e dataLength, dataPrecision, dataScale
|
||||||
// https://loopback.io/doc/en/lb3/Model-definition-JSON-file.html
|
// https://loopback.io/doc/en/lb3/Model-definition-JSON-file.html
|
||||||
if (colType) {
|
if (colType) {
|
||||||
if (colType === 'ENUM') return colType + '(' + enumList + ')';
|
|
||||||
if (colLength) return colType + '(' + colLength + ')';
|
if (colLength) return colType + '(' + colLength + ')';
|
||||||
if (colPrecision && colScale) return colType + '(' + colPrecision + ',' + colScale + ')';
|
if (colPrecision && colScale) return colType + '(' + colPrecision + ',' + colScale + ')';
|
||||||
if (colPrecision) return colType + '(' + colPrecision + ')';
|
if (colPrecision) return colType + '(' + colPrecision + ')';
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "loopback-connector-mysql",
|
"name": "loopback-connector-mysql",
|
||||||
"version": "7.1.1",
|
"version": "7.0.12",
|
||||||
"description": "MySQL connector for loopback-datasource-juggler",
|
"description": "MySQL connector for loopback-datasource-juggler",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
|
@ -21,23 +21,23 @@
|
||||||
"setup.sh"
|
"setup.sh"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^3.2.6",
|
"async": "^3.2.5",
|
||||||
"debug": "^4.4.0",
|
"debug": "^4.3.5",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"loopback-connector": "^6.2.2",
|
"loopback-connector": "^6.1.7",
|
||||||
"mysql2": "^3.6.3",
|
"mysql2": "^3.6.3",
|
||||||
"patch-package": "^8.0.0",
|
"patch-package": "^8.0.0",
|
||||||
"strong-globalize": "^6.0.6"
|
"strong-globalize": "^6.0.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/config-conventional": "^19.8.0",
|
"@commitlint/config-conventional": "^19.2.2",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.0",
|
||||||
"eslint-config-loopback": "^13.1.0",
|
"eslint-config-loopback": "^13.1.0",
|
||||||
"loopback-datasource-juggler": "^5.1.6",
|
"loopback-datasource-juggler": "^5.0.11",
|
||||||
"mocha": "^11.1.0",
|
"mocha": "^10.6.0",
|
||||||
"rc": "^1.2.8",
|
"rc": "^1.2.8",
|
||||||
"should": "^13.2.3",
|
"should": "^13.2.3",
|
||||||
"sinon": "^20.0.0"
|
"sinon": "^18.0.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -85,13 +85,6 @@ describe('migrations', function() {
|
||||||
Key: '',
|
Key: '',
|
||||||
Default: null,
|
Default: null,
|
||||||
Extra: ''},
|
Extra: ''},
|
||||||
typings: {
|
|
||||||
Field: 'typings',
|
|
||||||
Type: "enum('A','B')",
|
|
||||||
Null: 'YES',
|
|
||||||
Key: '',
|
|
||||||
Default: null,
|
|
||||||
Extra: ''},
|
|
||||||
});
|
});
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
@ -555,10 +548,9 @@ function setup(done) {
|
||||||
require('./init.js');
|
require('./init.js');
|
||||||
|
|
||||||
db = global.getSchema();
|
db = global.getSchema();
|
||||||
const customType = db.EnumFactory('A', 'B');
|
|
||||||
UserData = db.define('UserData', {
|
UserData = db.define('UserData', {
|
||||||
email: {type: String, null: false, index: true},
|
email: {type: String, null: false, index: true},
|
||||||
typings: {type: customType},
|
|
||||||
name: String,
|
name: String,
|
||||||
bio: Schema.Text,
|
bio: Schema.Text,
|
||||||
birthDate: Date,
|
birthDate: Date,
|
||||||
|
|
|
@ -283,21 +283,6 @@ describe('Discover LDL schema from a table', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Discover unique properties', function() {
|
|
||||||
let schema;
|
|
||||||
before(function(done) {
|
|
||||||
db.discoverSchema('CUSTOMER', {owner: 'STRONGLOOP'}, function(err, schema_) {
|
|
||||||
schema = schema_;
|
|
||||||
done(err);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
it('should validate unique key for customer', function() {
|
|
||||||
assert.ok(/STRONGLOOP/i.test(schema.options.mysql.schema));
|
|
||||||
assert.strictEqual(schema.options.mysql.table, 'CUSTOMER');
|
|
||||||
assert.strictEqual(schema.properties.email.index.unique, true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Discover and handle enum', function() {
|
describe('Discover and handle enum', function() {
|
||||||
let schema;
|
let schema;
|
||||||
before(function(done) {
|
before(function(done) {
|
||||||
|
@ -533,6 +518,7 @@ describe('Discover and build models', function() {
|
||||||
context('with flag treatTINYINT1AsTinyInt = false', function() {
|
context('with flag treatTINYINT1AsTinyInt = false', function() {
|
||||||
let models, schema;
|
let models, schema;
|
||||||
before(discoverAndBuildModels);
|
before(discoverAndBuildModels);
|
||||||
|
|
||||||
it('handles CHAR(1) as Boolean', function() {
|
it('handles CHAR(1) as Boolean', function() {
|
||||||
assert(schema.properties.enabled);
|
assert(schema.properties.enabled);
|
||||||
assert.strictEqual(schema.properties.enabled.type, Boolean);
|
assert.strictEqual(schema.properties.enabled.type, Boolean);
|
||||||
|
@ -582,11 +568,6 @@ describe('Discover and build models', function() {
|
||||||
assert.strictEqual(schema.properties.active.type, Boolean);
|
assert.strictEqual(schema.properties.active.type, Boolean);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles TINYINT as Boolean', function() {
|
|
||||||
assert(schema.properties.archived);
|
|
||||||
assert.strictEqual(schema.properties.archived.type, Boolean);
|
|
||||||
});
|
|
||||||
|
|
||||||
function discoverAndBuildModels(done) {
|
function discoverAndBuildModels(done) {
|
||||||
db.discoverAndBuildModels('INVENTORY', {
|
db.discoverAndBuildModels('INVENTORY', {
|
||||||
owner: 'STRONGLOOP',
|
owner: 'STRONGLOOP',
|
||||||
|
|
|
@ -39,8 +39,7 @@ CREATE TABLE `CUSTOMER` (
|
||||||
PRIMARY KEY (`ID`)
|
PRIMARY KEY (`ID`)
|
||||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
ALTER TABLE `CUSTOMER`
|
|
||||||
ADD COLUMN `email` VARCHAR(100) UNIQUE;
|
|
||||||
--
|
--
|
||||||
-- Dumping data for table `CUSTOMER`
|
-- Dumping data for table `CUSTOMER`
|
||||||
--
|
--
|
||||||
|
@ -81,7 +80,6 @@ CREATE TABLE `INVENTORY` (
|
||||||
`TOTAL` int(11) DEFAULT NULL,
|
`TOTAL` int(11) DEFAULT NULL,
|
||||||
`DETAILS` json DEFAULT NULL,
|
`DETAILS` json DEFAULT NULL,
|
||||||
`ACTIVE` BOOLEAN DEFAULT TRUE,
|
`ACTIVE` BOOLEAN DEFAULT TRUE,
|
||||||
`ARCHIVED` TINYINT DEFAULT 1,
|
|
||||||
`DISABLED` BIT(1) DEFAULT 0,
|
`DISABLED` BIT(1) DEFAULT 0,
|
||||||
`ENABLED` CHAR(1) DEFAULT 'Y',
|
`ENABLED` CHAR(1) DEFAULT 'Y',
|
||||||
PRIMARY KEY (`PRODUCT_ID`,`LOCATION_ID`),
|
PRIMARY KEY (`PRODUCT_ID`,`LOCATION_ID`),
|
||||||
|
|
Loading…
Reference in New Issue