profile
viewpoint

Ask questionsCant Use DefaultScope with sequelize.literal

<!-- Before submitting an issue, please consult our docs (https://github.com/RobinBuschmann/sequelize-typescript) and check whether your problem was already reported (https://github.com/RobinBuschmann/sequelize-typescript/issues) -->

<!-- Please make sure you are posting an issue pertaining to sequelize-typescript. If you are having an issue with sequelize itself, please consult the sequelize team (https://github.com/sequelize/sequelize/issues) -->

Versions <!-- Please let us know which sequelize, sequelize-typescript and typescript version are you using -->

  • sequelize: 5.8.5
  • sequelize-typescript: 1.0.0-alpha.9
  • typescript: 3.4.5

I'm submitting a ... <!-- (check one with "x") --> [x] bug report [ ] feature request

Actual behavior: calling .findAll + default scope with a custom attribute defined with a literal.

Expected behavior:

Steps to reproduce: This code producess

@Table({tableName: 'brocca'})
    @DefaultScope({
      attributes: [
        [sequelize.literal('meow'), 'aaa'],
      ],
    })
    class Brocca extends Model<Brocca> {

    }
    const bit = new Sequelize({dialect: 'postgres'});
    bit.addModels([Brocca]);
    await Brocca.findAll();

Stacktrace:

TypeError: attr[0].includes is not a function
    at attributes.map.attr (node_modules/sequelize/lib/dialects/abstract/query-generator.js:1383:29)
    at Array.map (<anonymous>)
    at PostgresQueryGenerator.escapeAttributes (node_modules/sequelize/lib/dialects/abstract/query-generator.js:1368:37)
    at PostgresQueryGenerator.selectQuery (node_modules/sequelize/lib/dialects/abstract/query-generator.js:1134:28)
    at QueryInterface.select (node_modules/sequelize/lib/query-interface.js:1120:27)
    at Promise.try.then.then.then (node_modules/sequelize/lib/model.js:1744:34)
    at tryCatcher (node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (node_modules/bluebird/js/release/promise.js:694:18)
    at _drainQueueStep (node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (node_modules/bluebird/js/release/async.js:17:14)

Related code: ...

RobinBuschmann/sequelize-typescript

Answer questions vekexasia

yes sorry :)

useful!
source:https://uonfu.com/
Github User Rank List