Closed romeerez closed 10 months ago
We might be using the insert type there, even though we should be using the update type. Thanks for the issue! We'll take a look soon.
updatedAt: (eb) => eb.sql
now()
,
This above syntax seems outdated.
As workaround I used this.
import { sql } from 'kysely';
export const bulkInsert = (rows: NewIssues[]) => {
const query = kyselyDB
.insertInto('table_name')
.values(rows)
.onConflict((oc) =>
oc.column('id').doUpdateSet({
updatedAt: (eb) => sql`now()`,
id: (eb) => eb.ref('excluded.id'),
}),
)
.compile();
console.log('sql =>\n', query.sql);
console.log('sql =>\n', query.parameters);
return query;
};
For those looking for a generic way to update all fields, see https://github.com/kysely-org/kysely/issues/677#issuecomment-2292177699
Hi, and thanks for maintaining this wonderful library!
I encountered a problem trying to set
updatedAt
insideonConflict
.TS error:
Looks like the problem is related to the fact that
updatedAt
is defined usingColumnType
.It's not critical though, I worked this around by changing the line inside
onConflict
to: