不要怂,就是干,撸起袖子干!

remove-constraint.test.js 917 Bytes
'use strict';

const Support   = require(__dirname + '/../support');
const current   = Support.sequelize;
const expectsql = Support.expectsql;
const sql = current.dialect.QueryGenerator;

if (current.dialect.supports.constraints.dropConstraint) {
  describe(Support.getTestDialectTeaser('SQL'), () => {
    describe('removeConstraint', () => {
      it('naming', () => {
        expectsql(sql.removeConstraintQuery('myTable', 'constraint_name'), {
          default: 'ALTER TABLE [myTable] DROP CONSTRAINT [constraint_name]'
        });
      });

      if (current.dialect.supports.schemas) {
        it('schema', () => {
          expectsql(sql.removeConstraintQuery({
            tableName: 'myTable',
            schema: 'inspections'
          }, 'constraint_name'), {
            default: 'ALTER TABLE [inspections].[myTable] DROP CONSTRAINT [constraint_name]'
          });
        });
      }
    });
  });
}