Ask questionsinclude[].on get an error: Error: Invalid value { '$col': '...' }

<!-- Before submitting an issue, please consult our docs ( and check whether your problem was already reported ( -->

<!-- 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 ( -->

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

  • sequelize: 5.8.8
  • sequelize-typescript: 1.0.0-alpha.9
  • typescript: 3.4.3

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

Actual behavior: <!-- Describe how the bug manifests. -->

code as below

        include: [
            model: User,
            as: 'maintainerInfo',
            on: {
              '$PSMUserRelation.maintainer$': { $col: 'maintainerInfo.user_id' }

get the error:

Error: Invalid value { '$col': 'maintainerInfo.user_id' }
    at Object.escape (/server/node_modules/sequelize/lib/sql-string.js:65:11)
    at MySQLQueryGenerator.escape (/server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:966:22)
    at MySQLQueryGenerator._whereParseSingleValueObject (/server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2433:41)
    at MySQLQueryGenerator.whereItemQuery (/server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2151:19)
    at Utils.getComplexKeys.forEach.prop (/server/node_modules/sequelize/lib/dialects/abstract/query-generator.js:2050:25)
    at Array.forEach (<anonymous>)
    at MySQLQueryGenerator.whereItemsQuery (/server/node_modules/sequelize/lib/dialects/abstract/query-gen...

Is there some thing I missing?

Expected behavior: <!-- Describe what the behavior would be without the bug. -->

work as it is


Answer questions RobinBuschmann

Hey @dancon, the $col syntax isn't supported anymore by sequelize. Use the following instead:

import {Op} from 'sequelize';

            on: {
              '$PSMUserRelation.maintainer$': { [Op.col]: 'maintainerInfo.user_id' }

See docs for further information.

Hope this helps. Feel free to close this issue if my answer solves your issue!

Github User Rank List