overlookmotel / sequelize-hierarchy

Nested hierarchies for Sequelize
MIT License
302 stars 90 forks source link

May be bug with top level records #228

Closed dcromster closed 3 years ago

dcromster commented 3 years ago

Hello!

If set ParentId to null, then when requested, the null is exceeded to 0.

part of error text:

sql: 'INSERT INTO `config_pricelists` (`id`,`keyName`,`keyValue`,`keyType`,`keyKind`,`**parentId**`,`createdAt`,`updatedAt`,`hierarchyLevel`) VALUES (DEFAULT,?,?,?,?,?,?,?,?);',
 parameters: [
    'test',
    '',
    0,
    'string',
    **0,**
    '2021-01-14 12:22:02',
    '2021-01-14 12:22:02',
    1
  ],
  fields: [ 'parentId' ],
  table: 'config_pricelists',
  value: undefined,
  index: 'config_pricelists_ibfk_1',
  reltype: 'child'
}

My object with params for insert record:

{ name: 'test', parentID: 0, type: 0, kind: 'string', **parentId: null** }

Node: v12.16.1 sequelize: 5.10.1 sequelize-hierarchy: a2.0.4

overlookmotel commented 3 years ago

You haven't given enough information to diagnose this.

But I notice in "object with params for insert record" there's parentID: 0. That is likely the cause.

I'm closing this for now as it doesn't look like it's a bug in sequelize-hierarchy from info provided. If you can produce a repeatable reproduction that demonstrates otherwise, I'll be happy to re-open and investigate.