dmfay / massive-js

A data mapper for Node.js and PostgreSQL.
2.49k stars 158 forks source link

I am getting error for deep insert and not sure why. #552

Closed jnystrom closed 6 years ago

jnystrom commented 6 years ago

The array of data trying to be inserted:

const dataToSave = [ { e_id: '1ed4-40c6-bd7e-2656154c7c15',
    a_id: '1ed4-40c6-bd7e-2656154c7c15',
    r_id: '17854d1d-8d6e-45f0-ada2',
    ABC_GLCODE: 'something',
    ABC_GLDESC: 'something',
    ABC_PL_FLAG: 'AB',
    ABC_ACTYPE: 'something',
    ABC_FSLI: 'something' },
  { e_id: '1ed4-40c6-bd7e-2656154c7c15',
    a_id: '1ed4-40c6-bd7e-2656154c7c15',
    r_id: '8d6e-45f0-ada2-e6f16b2f7bc1',
    ABC_GLCODE: 'something2',
    ABC_GLDESC: 'somethign2',
    ABC_PL_FLAG: 'something2',
    ABC_ACTYPE: 'something2',
    ABC_FSLI: 'something2' } ]

I am inserting the array:

await db[tableName].insert(dataToSave);

and I am getting error:

Exception has occurred: Error
Promise Rejection (Error: Deep insert is only supported for single records)
Error: Deep insert is only supported for single records
dmfay commented 6 years ago

Can you post the table definition?

jnystrom commented 6 years ago

Ok, I figured it out, it had to do with the case of the fields vs db...my fault. It was a strange error, but that was the reason.