triangle-utils 1.4.123 → 1.4.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -110,6 +110,9 @@ export class UtilsRDS {
110
110
  }
111
111
  }
112
112
  async batch_create(table_id, items, options = {}) {
113
+ if (items.length === 0) {
114
+ return;
115
+ }
113
116
  const attribute_names = Array.from(new Set(items.map(item => Object.keys(item)).flat())).sort();
114
117
  const sql = "INSERT INTO " + table_id + " (" + attribute_names.join(", ") + ")" + " VALUES " + items.map(item => "(" + attribute_names.map(attribute_name => convert_rds_input(item[attribute_name])).join(", ") + ")").join(", ") + " ON CONFLICT ON CONSTRAINT " + table_id + "_pkey IGNORE;";
115
118
  try {
@@ -134,6 +137,9 @@ export class UtilsRDS {
134
137
  }
135
138
  }
136
139
  async batch_put(table_id, items, options = {}) {
140
+ if (items.length === 0) {
141
+ return;
142
+ }
137
143
  const attribute_names = Array.from(new Set(items.map(item => Object.keys(item)).flat())).sort();
138
144
  const sql = "INSERT INTO " + table_id + " (" + attribute_names.join(", ") + ")" + " VALUES " + items.map(item => "(" + attribute_names.map(attribute_name => convert_rds_input(item[attribute_name])).join(", ") + ")").join(", ") + " ON CONFLICT ON CONSTRAINT " + table_id + "_pkey DO UPDATE SET " + attribute_names.map(attribute_name => attribute_name + " = " + "EXCLUDED." + attribute_name).join(", ") + ";";
139
145
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triangle-utils",
3
- "version": "1.4.123",
3
+ "version": "1.4.124",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "directories": {
package/src/UtilsRDS.ts CHANGED
@@ -160,6 +160,9 @@ export class UtilsRDS {
160
160
  is_verbose? : boolean
161
161
  } = {}
162
162
  ) {
163
+ if (items.length === 0) {
164
+ return
165
+ }
163
166
  const attribute_names = Array.from(new Set(items.map(item => Object.keys(item)).flat())).sort()
164
167
  const sql = "INSERT INTO " + table_id + " (" + attribute_names.join(", ") + ")" + " VALUES " + items.map(item => "(" + attribute_names.map(attribute_name => convert_rds_input(item[attribute_name])).join(", ") + ")").join(", ") + " ON CONFLICT ON CONSTRAINT " + table_id + "_pkey IGNORE;"
165
168
  try {
@@ -196,6 +199,9 @@ export class UtilsRDS {
196
199
  is_verbose? : boolean
197
200
  } = {}
198
201
  ) {
202
+ if (items.length === 0) {
203
+ return
204
+ }
199
205
  const attribute_names = Array.from(new Set(items.map(item => Object.keys(item)).flat())).sort()
200
206
  const sql = "INSERT INTO " + table_id + " (" + attribute_names.join(", ") + ")" + " VALUES " + items.map(item => "(" + attribute_names.map(attribute_name => convert_rds_input(item[attribute_name])).join(", ") + ")").join(", ") + " ON CONFLICT ON CONSTRAINT " + table_id + "_pkey DO UPDATE SET " + attribute_names.map(attribute_name => attribute_name + " = " + "EXCLUDED." + attribute_name).join(", ") + ";"
201
207
  try {