7226-testToMaster_2416 #2320

Merged
alexm merged 188 commits from 7226-testToMaster_2416 into master 2024-04-18 05:39:36 +00:00
4 changed files with 425 additions and 353 deletions
Showing only changes of commit 6c1e44638e - Show all commits

View File

@ -1 +1,15 @@
CREATE OR REPLACE TEMPORARY TABLE tmp.claimsWithHasToPickUp
SELECT id
FROM vn.claim
WHERE hasToPickUp;
ALTER TABLE vn.claim CHANGE hasToPickUp pickup ENUM('agency', 'delivery') DEFAULT NULL; ALTER TABLE vn.claim CHANGE hasToPickUp pickup ENUM('agency', 'delivery') DEFAULT NULL;
UPDATE vn.claim c
JOIN tmp.claimsWithHasToPickUp tmp ON tmp.id = c.id
SET c.pickup = 'delivery';
DROP TEMPORARY TABLE tmp.claimsWithHasToPickUp;
INSERT INTO salix.ACL (model,property,accessType,principalId)
VALUES ('Application','getEnumValues','*','employee');

View File

@ -0,0 +1,56 @@
const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
const UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethod('getEnumValues', {
description: 'Return enum values of column',
accessType: 'EXECUTE',
accepts: [
{
arg: 'schema',
type: 'string',
description: 'The schema of db',
required: true,
},
{
arg: 'table',
type: 'string',
description: 'The table of schema',
required: true,
},
{
arg: 'column',
type: 'string',
description: 'The column of table',
required: true,
},
],
returns: {
type: 'any',
root: true
},
http: {
path: `/get-enum-values`,
verb: 'GET'
}
});
Self.getEnumValues = async(schema, table, column) => {
const stmt = new ParameterizedSQL(`
SELECT COLUMN_TYPE
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = ?
AND TABLE_NAME = ?
AND COLUMN_NAME = ?
AND DATA_TYPE = 'enum';`,
[schema, table, column]);
const conn = Self.dataSource.connector;
const [result] = await conn.executeStmt(stmt);
if (!result) throw new UserError(`No results found`);
const regex = /'([^']*)'/g;
return result.COLUMN_TYPE.match(regex).map(match => match.slice(1, -1));
};
};

View File

@ -5,4 +5,5 @@ module.exports = function(Self) {
require('../methods/application/execute')(Self); require('../methods/application/execute')(Self);
require('../methods/application/executeProc')(Self); require('../methods/application/executeProc')(Self);
require('../methods/application/executeFunc')(Self); require('../methods/application/executeFunc')(Self);
require('../methods/application/getEnumValues')(Self);
}; };

View File

@ -351,5 +351,6 @@
"The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas", "The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas",
"The line could not be marked": "La linea no puede ser marcada", "The line could not be marked": "La linea no puede ser marcada",
"This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario", "This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario",
"They're not your subordinate": "No es tu subordinado/a." "They're not your subordinate": "No es tu subordinado/a.",
"No results found": "No se han encontrado resultados"
} }