diff --git a/integration-tests/__tests__/object-analyse.spec.js b/integration-tests/__tests__/object-analyse.spec.js index 8a8956dd5..55e23000e 100644 --- a/integration-tests/__tests__/object-analyse.spec.js +++ b/integration-tests/__tests__/object-analyse.spec.js @@ -158,6 +158,13 @@ describe('Object analyse', () => { const createdTrigger = structure[objectTypeField].find(x => x.pureName == expected.pureName); expect(createdTrigger).toEqual(expect.objectContaining(expected)); + + // test trigger createSql + if (triggerOtherCreateSql) await runCommandOnDriver(conn, driver, triggerOtherCreateSql); + await runCommandOnDriver(conn, driver, createdTrigger.createSql); + const structure2 = await driver.analyseFull(conn); + const createdTrigger2 = structure2[objectTypeField].find(x => x.pureName == expected.pureName); + expect(createdTrigger2).toEqual(expect.objectContaining(expected)); }) ); }); diff --git a/integration-tests/engines.js b/integration-tests/engines.js index 9e01ff1d2..fc7ac634d 100644 --- a/integration-tests/engines.js +++ b/integration-tests/engines.js @@ -354,6 +354,13 @@ const sqlServerEngine = { drop1: 'DROP PROCEDURE obj1', drop2: 'DROP PROCEDURE obj2', }, + { + type:'triggers', + create1: 'CREATE TRIGGER obj1 ON t1 AFTER INSERT AS BEGIN SELECT * FROM t1 END', + create2: 'CREATE TRIGGER obj2 ON t2 AFTER INSERT AS BEGIN SELECT * FROM t2 END', + drop1: 'DROP TRIGGER obj1', + drop2: 'DROP TRIGGER obj2', + } ], parametersOtherSql: ['CREATE PROCEDURE obj2 (@p1 int, @p2 int) AS SELECT id from t1'], parameters: [ @@ -419,14 +426,8 @@ const sqlServerEngine = { triggers: [ { testName: 'triggers before each row', - create: `CREATE TRIGGER obj1 -ON t1 -AFTER INSERT -AS -BEGIN -SELECT * FROM t1 -END;`, - drop: 'DROP TRIGGER obj1;', + create: `CREATE TRIGGER obj1 ON t1 AFTER INSERT AS BEGIN SELECT * FROM t1 END`, + drop: 'DROP TRIGGER obj1', objectTypeField: 'triggers', expected: { pureName: 'obj1', @@ -436,14 +437,8 @@ END;`, }, { testName: 'triggers before each row', - create: `CREATE TRIGGER obj1 -ON t1 -AFTER UPDATE -AS -BEGIN -SELECT * FROM t1 -END;`, - drop: 'DROP TRIGGER obj1;', + create: `CREATE TRIGGER obj1 ON t1 AFTER UPDATE AS BEGIN SELECT * FROM t1 END`, + drop: 'DROP TRIGGER obj1', objectTypeField: 'triggers', expected: { pureName: 'obj1', @@ -580,17 +575,17 @@ const enginesOnCi = [ oracleEngine, ]; -const enginesOnLocal = { +const enginesOnLocal = [ // all engines, which would be run on local test - mysqlEngine, - mariaDbEngine, - postgreSqlEngine, + // mysqlEngine, + // mariaDbEngine, + // postgreSqlEngine, sqlServerEngine, - sqliteEngine, - cockroachDbEngine, - clickhouseEngine, - oracleEngine, -}; + // sqliteEngine, + // cockroachDbEngine, + // clickhouseEngine, + // oracleEngine, +]; module.exports = process.env.CITEST ? enginesOnCi : enginesOnLocal; diff --git a/plugins/dbgate-plugin-mssql/src/backend/sql/modifications.js b/plugins/dbgate-plugin-mssql/src/backend/sql/modifications.js index b1a2fec1d..0fb43f404 100644 --- a/plugins/dbgate-plugin-mssql/src/backend/sql/modifications.js +++ b/plugins/dbgate-plugin-mssql/src/backend/sql/modifications.js @@ -2,6 +2,6 @@ module.exports = ` select o.object_id as objectId, o.modify_date as modifyDate, o.type, o.name as pureName, s.name as schemaName from sys.objects o inner join sys.schemas s on o.schema_id = s.schema_id -where o.type in ('U', 'V', 'P', 'IF', 'FN', 'TF') -- , 'TR' - triggers disabled +where o.type in ('U', 'V', 'P', 'IF', 'FN', 'TF', 'TR') and s.name =SCHEMA_NAME_CONDITION `;