Skip to content

Commit 32e220c

Browse files
committed
chore(docs): add note re: defaultToNull
1 parent 2f4df87 commit 32e220c

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/PostgrestQueryBuilder.ts

+35-2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ export default class PostgrestQueryBuilder<
9696
} as unknown as PostgrestBuilder<ResultOne[]>)
9797
}
9898

99+
// TODO(v3): Make `defaultToNull` consistent for both single & bulk inserts.
100+
insert<Row extends Relation extends { Insert: unknown } ? Relation['Insert'] : never>(
101+
values: Row,
102+
options?: {
103+
count?: 'exact' | 'planned' | 'estimated'
104+
}
105+
): PostgrestFilterBuilder<Schema, Relation['Row'], null, Relationships>
106+
insert<Row extends Relation extends { Insert: unknown } ? Relation['Insert'] : never>(
107+
values: Row[],
108+
options?: {
109+
count?: 'exact' | 'planned' | 'estimated'
110+
defaultToNull?: boolean
111+
}
112+
): PostgrestFilterBuilder<Schema, Relation['Row'], null, Relationships>
99113
/**
100114
* Perform an INSERT into the table or view.
101115
*
@@ -119,7 +133,8 @@ export default class PostgrestQueryBuilder<
119133
* numbers.
120134
*
121135
* @param options.defaultToNull - Make missing fields default to `null`.
122-
* Otherwise, use the default value for the column.
136+
* Otherwise, use the default value for the column. Only applies for bulk
137+
* inserts.
123138
*/
124139
insert<Row extends Relation extends { Insert: unknown } ? Relation['Insert'] : never>(
125140
values: Row | Row[],
@@ -164,6 +179,24 @@ export default class PostgrestQueryBuilder<
164179
} as unknown as PostgrestBuilder<null>)
165180
}
166181

182+
// TODO(v3): Make `defaultToNull` consistent for both single & bulk upserts.
183+
upsert<Row extends Relation extends { Insert: unknown } ? Relation['Insert'] : never>(
184+
values: Row,
185+
options?: {
186+
onConflict?: string
187+
ignoreDuplicates?: boolean
188+
count?: 'exact' | 'planned' | 'estimated'
189+
}
190+
): PostgrestFilterBuilder<Schema, Relation['Row'], null, Relationships>
191+
upsert<Row extends Relation extends { Insert: unknown } ? Relation['Insert'] : never>(
192+
values: Row[],
193+
options?: {
194+
onConflict?: string
195+
ignoreDuplicates?: boolean
196+
count?: 'exact' | 'planned' | 'estimated'
197+
defaultToNull?: boolean
198+
}
199+
): PostgrestFilterBuilder<Schema, Relation['Row'], null, Relationships>
167200
/**
168201
* Perform an UPSERT on the table or view. Depending on the column(s) passed
169202
* to `onConflict`, `.upsert()` allows you to perform the equivalent of
@@ -200,7 +233,7 @@ export default class PostgrestQueryBuilder<
200233
* @param options.defaultToNull - Make missing fields default to `null`.
201234
* Otherwise, use the default value for the column. This only applies when
202235
* inserting new rows, not when merging with existing rows under
203-
* `ignoreDuplicates: false`.
236+
* `ignoreDuplicates: false`. This also only applies when doing bulk upserts.
204237
*/
205238
upsert<Row extends Relation extends { Insert: unknown } ? Relation['Insert'] : never>(
206239
values: Row | Row[],

0 commit comments

Comments
 (0)