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

Code before:
        }), {
          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'],
          }), {
            default: 'CREATE INDEX [email_include_name] ON [User] ([email]) INCLUDE ([first_name], [last_name])',
          });
        }
      });
    }

Review comment (security):
could you add a test where `include` is a literal, and `include` is an array of literals? We try to support literal everywhere as an escape hatch

```ts
include: [literal('first_name')],

//

include: literal('(first_name, last_name)'),
```

it should add them as-is without further processing

Code after:
          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',  {
        name: 'email_include_name',
        fields: ['email'],
        include: ['first_name', 'last_name'],
      }), {
        db2: new Error('DB2 does not support non-unique indexes with INCLUDE syntax.'),