Reputation: 179
I using mysql database and objection.js for handling my database actions.When I am trying to insert values, I am getting R_BAD_FIELD_ERROR: Unknown column 'table' in 'field list'. This is the code I am using for the insert data,
Modelclass.query()
.insert( { storeId: xxxxxx,
itemLocalName: 'LSストレ',
itemCode: xxxxxx,
itemType: '',
skus: xxxxxx,
itemLevel: 'L2',
colorCode: '99',
colorName: 'Other',
regionCode: 'jqs' } )
.then(function () {
console.log( 'inserted' );
}).catch( function( err ) {
console.log( 'error while inserting, error : ' + err );
});
and the generated query is:
insert into `sampleTable` (`colorCode`, `colorName`, `itemCode`, `itemLevel`,
`itemLocalName`, `itemType`, `regionCode`, `skus`, `storeId`, `table`)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )'
}
Error while inserting:
insert into `sampleTable` (`colorCode`, `colorName`, `itemCode`, `itemLevel`,
`itemLocalName`, `itemType`, `regionCode`, `skus`, `storeId`, `table`)
values ('99', 'Other', 'xxxxxx', 'L2', 'LSストレ', '','jqs', 'xxxxxx', 'xxxxxx', 'sampleTable')
and the table field is included by the objection.js which is not there in my sampleTable
Please help me to solve this issue.
Upvotes: 1
Views: 923
Reputation: 250
There is something in your model definition that adds the table
column. Objection doesn't do this. It is impossible to tell you what it is without seeing the model, but I have a couple of ideas:
$formatDatabaseJson
method, you may be adding that column by accident.Adding the model class definition to the question would provide better answers.
Upvotes: 2