@asla/yoursql 0.1.1 → 0.1.2

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.
package/dist/mod.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from "./select/type.ts";
4
4
  export * from "./select/select.ts";
5
5
  export * from "./select/selectable.ts";
6
6
  export * from "./select/TableQuery.ts";
7
+ export * from "./util.ts";
7
8
  //# sourceMappingURL=mod.d.ts.map
package/dist/mod.js CHANGED
@@ -33,6 +33,28 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
33
33
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
34
34
  };
35
35
 
36
+ /**
37
+ * @public
38
+ * @param keepUndefinedKey - 是否保留值为 undefined 的 key
39
+ */
40
+ function getObjectListKeys(objectList, keepUndefinedKey) {
41
+ let keys = new Set();
42
+ for (let i = 0; i < objectList.length; i++) {
43
+ let obj = objectList[i];
44
+ let hasKeys = Object.keys(obj);
45
+ let k;
46
+ for (let j = 0; j < hasKeys.length; j++) {
47
+ k = hasKeys[j];
48
+ if (typeof k !== "string")
49
+ continue;
50
+ if (!keepUndefinedKey && obj[k] === undefined)
51
+ continue;
52
+ keys.add(k);
53
+ }
54
+ }
55
+ return Array.from(keys);
56
+ }
57
+
36
58
  var _SqlRaw_value;
37
59
  /**
38
60
  * SQL 原始字符对象
@@ -205,27 +227,6 @@ function toKeyType(object, keys_types) {
205
227
  }
206
228
  return { type, keys };
207
229
  }
208
- /**
209
- * @public
210
- * @param keepUndefinedKey - 是否保留值为 undefined 的 key
211
- */
212
- function getObjectListKeys(objectList, keepUndefinedKey) {
213
- let keys = new Set();
214
- for (let i = 0; i < objectList.length; i++) {
215
- let obj = objectList[i];
216
- let hasKeys = Object.keys(obj);
217
- let k;
218
- for (let j = 0; j < hasKeys.length; j++) {
219
- k = hasKeys[j];
220
- if (typeof k !== "string")
221
- continue;
222
- if (!keepUndefinedKey && obj[k] === undefined)
223
- continue;
224
- keys.add(k);
225
- }
226
- }
227
- return Array.from(keys);
228
- }
229
230
 
230
231
  /** @public PgSql 转换器 */
231
232
  const pgSqlTransformer = new Map([
@@ -603,7 +604,7 @@ class DbTableQuery extends DbTable {
603
604
  if (values instanceof Array) {
604
605
  if (values.length === 0)
605
606
  throw new Error("值不能为空");
606
- insertCol = Object.keys(values[0]);
607
+ insertCol = getObjectListKeys(values);
607
608
  valuesStr = `VALUES\n${this.statement.objectListToValuesList(values, insertCol)}`;
608
609
  }
609
610
  else if (values instanceof SqlQueryStatement) {
@@ -66,10 +66,5 @@ export declare class SqlValuesCreator {
66
66
  */
67
67
  toValues(values: readonly any[]): string;
68
68
  }
69
- /**
70
- * @public
71
- * @param keepUndefinedKey - 是否保留值为 undefined 的 key
72
- */
73
- export declare function getObjectListKeys(objectList: any[], keepUndefinedKey?: boolean): string[];
74
69
  export {};
75
70
  //# sourceMappingURL=sql_value.d.ts.map
package/dist/util.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @public
3
+ * @param keepUndefinedKey - 是否保留值为 undefined 的 key
4
+ */
5
+ export declare function getObjectListKeys(objectList: any[], keepUndefinedKey?: boolean): string[];
6
+ //# sourceMappingURL=util.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asla/yoursql",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "types": "./dist/mod.d.ts",