You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
yariksav
changed the title
attach() with pivotPrimaryKey(false) throws error "Cannot read property '0' of undefined" when
attach() with pivotPrimaryKey(false) throws error "Cannot read property '0' of undefined"
Aug 17, 2019
I was having a simular issue when trying to insert related models with a pivot table without a primary key:
{ error: column "id" does not exist
at Connection.parseE (node_modules\pg\lib\connection.js:604:11)
at Connection.parseMessage (node_modules\pg\lib\connection.js:401:19)
at Socket.<anonymous> (node_modules\pg\lib\connection.js:121:22)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
...
}
But adding pivotPrimaryKey to the model seemed to solve the problem with both false and null as parameters:
Based on #287 issue, I think I should be reopened.
For disable returning id in pivot table we made possibility to set pivotPrimaryKey null or false
provided correct sql insert:
but it throws error:
Cannot read property '0' of undefined
After investigation - model.js always try to get [0] index of result when incrementing=true, but now it's undefined
https://github.com/adonisjs/adonis-lucid/blob/6cd666df9534a981f4bd99ac0812a44d1685728a/src/Lucid/Model/index.js#L620-L622 How to disable incrementing in pivot i don't know
PS: in commit 0cb13bf#diff-6d18536778f7ef94da4ab8fc5ae2fb76R2641 test only check is sql insert correct, but doesn't check real inserting pivot row
The text was updated successfully, but these errors were encountered: