@quillsql/node 0.4.1 → 0.4.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.
@@ -173,9 +173,18 @@ function inferType(elem) {
173
173
  // Check if the number is a float or an integer
174
174
  return Number.isInteger(elem) ? 23 : 700; // 23: integer, 700: real
175
175
  }
176
+ // BIG QUERY places data into objects as well
176
177
  if (typeof elem === "object") {
177
178
  if (/^\d{4}-\d{2}-\d{2}$/.test(elem.value))
178
- return 1082; // date
179
+ return 1082; // YYYY-MM-DD format
180
+ if (/^\d{2}\/\d{2}\/\d{2,4}$/.test(elem.value))
181
+ return 1082; // MM\DD\YYYY or MM\DD\YY format
182
+ if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?$/.test(elem.value))
183
+ return 1114; // YYYY-MM-DDTHH:MM:SS[.fraction] format
184
+ if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/.test(elem.value))
185
+ return 1184; // YYYY-MM-DDTHH:MM:SS[.fraction]Z format
186
+ if (/^\d{2}:\d{2}:\d{2}$/.test(elem.value))
187
+ return 1083; // HH:MM:SS format
179
188
  }
180
189
  if (typeof elem === "string") {
181
190
  // Attempt to infer date, time, and timestamp formats
package/dist/index.js CHANGED
@@ -49,6 +49,9 @@ class QuillClass {
49
49
  };
50
50
  }
51
51
  const response = yield this.postQuill(metadata.task, Object.assign(Object.assign(Object.assign({}, metadata), preQueryResults), { orgId, viewQuery: metadata.preQueries ? metadata.preQueries[0] : undefined }));
52
+ if (response.error) {
53
+ return { status: "error", error: response.error };
54
+ }
52
55
  // if there is no metadata object in the response, create one
53
56
  if (!response.metadata) {
54
57
  response.metadata = {};
@@ -103,7 +106,7 @@ class QuillClass {
103
106
  return Object.assign(Object.assign({}, results), { queryResults: [], mappedArray });
104
107
  }
105
108
  else if (runQueryConfig === null || runQueryConfig === void 0 ? void 0 : runQueryConfig.getColumns) {
106
- const queryResult = yield this.targetConnection.query(`${queries[0]} limit 1`);
109
+ const queryResult = yield this.targetConnection.query(`${queries[0].replace(/;/, "")} limit 1`);
107
110
  const columns = queryResult.fields.map((field) => {
108
111
  return {
109
112
  fieldType: (0, schemaConversion_1.convertTypeToPostgres)(field.dataTypeID),
@@ -126,6 +129,11 @@ class QuillClass {
126
129
  return query.replace(/;/, "") + " limit 1000;";
127
130
  });
128
131
  }
132
+ else if (runQueryConfig === null || runQueryConfig === void 0 ? void 0 : runQueryConfig.limitBy) {
133
+ queries = queries.map((query) => {
134
+ return query.replace(/;/, "") + " limit " + runQueryConfig.limitBy;
135
+ });
136
+ }
129
137
  const queryResults = yield Promise.all(queries.map((query) => __awaiter(this, void 0, void 0, function* () {
130
138
  return yield this.targetConnection.query(query);
131
139
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quillsql/node",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Quill's client SDK for node backends.",
5
5
  "main": "dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -36,4 +36,4 @@
36
36
  "snowflake-sdk": "^1.9.3",
37
37
  "ts-jest": "^29.1.1"
38
38
  }
39
- }
39
+ }