不要怂,就是干,撸起袖子干!

Commit 143cc84c by JacobLey Committed by GitHub

fix(typings): `returning` can specify column names (#13215)

1 parent 8f2a0d52
Showing with 10 additions and 6 deletions
...@@ -719,7 +719,7 @@ export interface UpsertOptions<TAttributes = any> extends Logging, Transactionab ...@@ -719,7 +719,7 @@ export interface UpsertOptions<TAttributes = any> extends Logging, Transactionab
/** /**
* Return the affected rows (only for postgres) * Return the affected rows (only for postgres)
*/ */
returning?: boolean; returning?: boolean | (keyof TAttributes)[];
/** /**
* Run validations before the row is inserted * Run validations before the row is inserted
......
import {Model} from "sequelize" import {Model} from "sequelize"
import {sequelize} from './connection'; import {sequelize} from './connection';
class TestModel extends Model { class TestModel extends Model<{ foo: string; bar: string }, {}> {
} }
TestModel.init({}, {sequelize}) TestModel.init({
foo: '<foo>',
bar: '<bar>',
}, {sequelize})
sequelize.transaction(async trx => { sequelize.transaction(async trx => {
const res1: [TestModel, boolean | null] = await TestModel.upsert<TestModel>({}, { const res1: [TestModel, boolean | null] = await TestModel.upsert<TestModel>({}, {
benchmark: true, benchmark: true,
fields: ['testField'], fields: ['foo'],
hooks: true, hooks: true,
logging: true, logging: true,
returning: true, returning: true,
...@@ -20,7 +23,7 @@ sequelize.transaction(async trx => { ...@@ -20,7 +23,7 @@ sequelize.transaction(async trx => {
const res2: [TestModel, boolean | null] = await TestModel.upsert<TestModel>({}, { const res2: [TestModel, boolean | null] = await TestModel.upsert<TestModel>({}, {
benchmark: true, benchmark: true,
fields: ['testField'], fields: ['foo'],
hooks: true, hooks: true,
logging: true, logging: true,
returning: false, returning: false,
...@@ -31,9 +34,10 @@ sequelize.transaction(async trx => { ...@@ -31,9 +34,10 @@ sequelize.transaction(async trx => {
const res3: [TestModel, boolean | null] = await TestModel.upsert<TestModel>({}, { const res3: [TestModel, boolean | null] = await TestModel.upsert<TestModel>({}, {
benchmark: true, benchmark: true,
fields: ['testField'], fields: ['foo'],
hooks: true, hooks: true,
logging: true, logging: true,
returning: ['foo'],
searchPath: 'DEFAULT', searchPath: 'DEFAULT',
transaction: trx, transaction: trx,
validate: true, validate: true,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!