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

Commit 761158cc by Simon Schick Committed by GitHub

fix(query-interface): allow passing null for query interface insert (#11931)

1 parent f1ba2808
...@@ -151,10 +151,10 @@ export interface WhereOperators { ...@@ -151,10 +151,10 @@ export interface WhereOperators {
[Op.lte]?: number | string | Date | Literal; [Op.lte]?: number | string | Date | Literal;
/** Example: `[Op.ne]: 20,` becomes `!= 20` */ /** Example: `[Op.ne]: 20,` becomes `!= 20` */
[Op.ne]?: string | number | Literal | WhereOperators; [Op.ne]?: null | string | number | Literal | WhereOperators;
/** Example: `[Op.not]: true,` becomes `IS NOT TRUE` */ /** Example: `[Op.not]: true,` becomes `IS NOT TRUE` */
[Op.not]?: boolean | string | number | Literal | WhereOperators; [Op.not]?: null | boolean | string | number | Literal | WhereOperators;
/** Example: `[Op.between]: [6, 10],` becomes `BETWEEN 6 AND 10` */ /** Example: `[Op.between]: [6, 10],` becomes `BETWEEN 6 AND 10` */
[Op.between]?: [number, number]; [Op.between]?: [number, number];
......
...@@ -451,7 +451,7 @@ export class QueryInterface { ...@@ -451,7 +451,7 @@ export class QueryInterface {
/** /**
* Inserts a new record * Inserts a new record
*/ */
public insert(instance: Model, tableName: string, values: object, options?: QueryOptions): Promise<object>; public insert(instance: Model | null, tableName: string, values: object, options?: QueryOptions): Promise<object>;
/** /**
* Inserts or Updates a record in the database * Inserts or Updates a record in the database
...@@ -473,7 +473,7 @@ export class QueryInterface { ...@@ -473,7 +473,7 @@ export class QueryInterface {
records: object[], records: object[],
options?: QueryOptions, options?: QueryOptions,
attributes?: string[] | string attributes?: string[] | string
): Promise<object>; ): Promise<object | number>;
/** /**
* Updates a row * Updates a row
......
...@@ -53,7 +53,7 @@ queryInterface.dropTable('nameOfTheExistingTable'); ...@@ -53,7 +53,7 @@ queryInterface.dropTable('nameOfTheExistingTable');
queryInterface.bulkDelete({ tableName: 'foo', schema: 'bar' }, {}, {}); queryInterface.bulkDelete({ tableName: 'foo', schema: 'bar' }, {}, {});
queryInterface.bulkInsert({ tableName: 'foo', as: 'bar', name: 'as' }, [{}], {}); const bulkInsertRes: Promise<number | object> = queryInterface.bulkInsert({ tableName: 'foo', as: 'bar', name: 'as' }, [{}], {});
queryInterface.bulkUpdate({ tableName: 'foo', delimiter: 'bar', as: 'baz', name: 'quz' }, {}, {}); queryInterface.bulkUpdate({ tableName: 'foo', delimiter: 'bar', as: 'baz', name: 'quz' }, {}, {});
...@@ -181,3 +181,5 @@ queryInterface.delete(null, 'Person', { ...@@ -181,3 +181,5 @@ queryInterface.delete(null, 'Person', {
}); });
queryInterface.upsert("test", {"a": 1}, {"b": 2}, {"c": 3}, Model, {}); queryInterface.upsert("test", {"a": 1}, {"b": 2}, {"c": 3}, Model, {});
queryInterface.insert(null, 'test', {});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!