Repository: sequelize/sequelize
File: test/unit/sql/index.test.js (JavaScript)

Code before:
            name: 'column1',
            order: 'DESC',
            operator: 'inet_ops',
          }, 'column2'],
          using: 'gist',
        }), {
          postgres: 'CREATE INDEX "table_column1_column2" ON "table" USING gist ("column1" inet_ops DESC, "column2")',
        });
      });
      it('operator in multiple fields #2', () => {
        expectsql(sql.addIndexQuery('table', {
          fields: [{
            name: 'path',
            operator: 'text_pattern_ops',
          }, 'level', {
            name: 'name',
            operator: 'varchar_pattern_ops',
          }],
          using: 'btree',
        }), {
          postgres: 'CREATE INDEX "table_path_level_name" ON "table" USING btree ("path" text_pattern_ops, "level", "name" varchar_pattern_ops)',
        });
      });
    }

    if (current.dialect.supports.index.include) {
      it('include columns with unique index', () => {
        expectsql(sql.addIndexQuery('User',  {
          name: 'email_include_name',
          fields: ['email'],
          include: ['first_name', 'last_name'],
          unique: true,
        }), {
          default: 'CREATE UNIQUE INDEX [email_include_name] ON [User] ([email]) INCLUDE ([first_name], [last_name])',
        });
      });

      it('include columns with non-unique index', () => {
        if (current.dialect.name === 'db2') {
          // DB2 does not support non-unique indexes with include columns
          expect(() => sql.addIndexQuery('User',  {
            name: 'email_include_name',
            fields: ['email'],
            include: ['first_name', 'last_name'],
          })).to.throw('DB2 does not support non-unique indexes with INCLUDE syntax.');
        } else {
          expectsql(sql.addIndexQuery('User',  {
            name: 'email_include_name',
            fields: ['email'],
            include: ['first_name', 'last_name'],
          }), {

Review comment (suggestion):
this test should run on all dialects, but dialects that don't support it should check that an error is thrown. You can do it like this:

```ts
// arrow function so expectsql can catch the error
expectsql(() => sql.addIndexQuery('User',  {
  name: 'email_include_name',
  fields: ['email'],
  include: ['first_name', 'last_name'],
  unique: true,
}), {
  'mysql mariadb': new Error('Your error message here')
  postgres: 'CREATE UNIQUE INDEX [email_include_name] ON [User] ([email]) INCLUDE ([first_name], [last_name])',
});
```

Code after:
            order: 'DESC',
            operator: 'inet_ops',
          }],
          using: 'gist',
        }), {
          postgres: 'CREATE INDEX "table_column" ON "table" USING gist ("column" inet_ops DESC)',
        });
      });
      it('operator in multiple fields #1', () => {
        expectsql(sql.addIndexQuery('table', {
          fields: [{
            name: 'column1',
            order: 'DESC',
            operator: 'inet_ops',
          }, 'column2'],
          using: 'gist',
        }), {
          postgres: 'CREATE INDEX "table_column1_column2" ON "table" USING gist ("column1" inet_ops DESC, "column2")',
        });
      });
      it('operator in multiple fields #2', () => {
        expectsql(sql.addIndexQuery('table', {
          fields: [{
            name: 'path',
            operator: 'text_pattern_ops',
          }, 'level', {
            name: 'name',
            operator: 'varchar_pattern_ops',
          }],
          using: 'btree',
        }), {
          postgres: 'CREATE INDEX "table_path_level_name" ON "table" USING btree ("path" text_pattern_ops, "level", "name" varchar_pattern_ops)',
        });
      });
    }

    it('include columns with unique index', () => {
      expectsql(() => sql.addIndexQuery('User',  {
        name: 'email_include_name',
        fields: ['email'],
        include: ['first_name', 'last_name'],
        unique: true,
      }), {
        default: new Error(`The include attribute for indexes is not supported by ${current.dialect.name} dialect`),
        mssql: 'CREATE UNIQUE INDEX [email_include_name] ON [User] ([email]) INCLUDE ([first_name], [last_name])',
        'db2 postgres': 'CREATE UNIQUE INDEX "email_include_name" ON "User" ("email") INCLUDE ("first_name", "last_name")',
      });
    });

    it('include columns with non-unique index', () => {
      expectsql(() => sql.addIndexQuery('User',  {