knex: RAW insert does not return rows affected.
Environment
Knex version: 0.19.5 Database + version: oracle 11g 11.2 OS: Linux
Question:
@ atiertant
Knex.raw insert does not return a number of rows inserted to the table. It returns empty array [] But knex.insert() returns rows affected correctly.
Here is the sample code.
knex.insert(
insert into logtable (COL1, COL2) values (?, ?),
[col1Value, col2Value]
)
.then(count => {
console.log(count);
return count;
})
Am I missing anything?
Thanks!
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 15 (5 by maintainers)
Touche.
I’ll document
knex('logtable').insert(knex.raw('(COL1, COL2) values (?, ?)', val1, val2))and add a test then.Afaik that is not valid knex code… object or knex.raw should be give for insert and table name should be given separately.
This should work (even that probably there is no tests / documentation for this either):
Also you can check query output with
.toSQL()https://runkit.com/embed/tldgmsi5hqpvAlso it is possible to set column value as queries or raw, which should serve at least for reason 2:
closing as I couldn’t see any bugs here