Inserting into a table with no ID column gives `Invalid column name 'id'`
I keep getting this error whenever I try to insert using objection:
insert into [job_execution] ([last_run_at], [name]) output inserted.[id] values (@p0, @p1) - Invalid column name 'id'.
Code:
await JobExecution.query().insert([{
name: 'test'
last_run_at: new Date().toISOString(),
}]);
I've also tried it without the array (just a single object). The same error does not occur when adding the record through knex. Changing the migration file to include an ID column fixes the error but I don't need an id field.
How is your model?
How is your model?
It's just:
class JobExecution extends Model {
static get tableName() {
return 'job_execution';
}
// static methods for getting and updating the table
}
Do you have a custom primary key column? You can customize it on your model:
https://vincit.github.io/objection.js/recipes/custom-id-column.html
Do you have a custom primary key column? You can customize it on your model:
https://vincit.github.io/objection.js/recipes/custom-id-column.html
Can I not have the table without a primary key column? I have another table that doesn't have one and this table is copied directly from that but only this one is having problems
Hi @KrisLau, is this issue still happening? I tried to reproduce and I didn't get the same result.
@grazirs It is yeah but I'm unsure what is causing it. I have another table that doesn't have an ID but it's not having a problem and all the code for this table is copied exactly from that one.
All tables should include the primary key, and the objection insert script is not working without the primary key on my end. But I dont think its the issue on the library, because in DBA, we have to use the indexing even if we design the relation table for the M:N relationship
All tables should include the primary key, and the objection insert script is not working without the primary key on my end. But I dont think its the issue on the library, because in DBA, we have to use the indexing even if we design the relation table for the M:N relationship
@iSeanWeiDev But for some reason it is allowing one table without a primary key and not allowing another