@malloydata/db-mysql 0.0.391 → 0.0.392
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/mysql_connection.js +10 -5
- package/package.json +3 -2
package/dist/mysql_connection.js
CHANGED
|
@@ -44,6 +44,13 @@ const malloy_1 = require("@malloydata/malloy");
|
|
|
44
44
|
const connection_1 = require("@malloydata/malloy/connection");
|
|
45
45
|
const crypto_1 = require("crypto");
|
|
46
46
|
const MYSQL = __importStar(require("mysql2/promise"));
|
|
47
|
+
/**
|
|
48
|
+
* A bare or schema-qualified SQL identifier — `name` or `db.name`. Anything
|
|
49
|
+
* else (dashes, dots-as-extensions, slashes, special characters) needs to be
|
|
50
|
+
* wrapped in backticks for `DESCRIBE` to parse it as one identifier rather
|
|
51
|
+
* than e.g. parsing `my-table` as subtraction.
|
|
52
|
+
*/
|
|
53
|
+
const SQL_IDENTIFIER_CHAIN = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/;
|
|
47
54
|
class MySQLExecutor {
|
|
48
55
|
static getConnectionOptionsFromEnv() {
|
|
49
56
|
const user = process.env['MYSQL_USER'];
|
|
@@ -160,9 +167,9 @@ class MySQLConnection extends connection_1.BaseConnection {
|
|
|
160
167
|
connection: this.name,
|
|
161
168
|
fields: [],
|
|
162
169
|
};
|
|
163
|
-
const quotedTablePath =
|
|
164
|
-
?
|
|
165
|
-
: tablePath
|
|
170
|
+
const quotedTablePath = SQL_IDENTIFIER_CHAIN.test(tablePath)
|
|
171
|
+
? tablePath
|
|
172
|
+
: `\`${tablePath}\``;
|
|
166
173
|
const infoQuery = `DESCRIBE ${quotedTablePath}`;
|
|
167
174
|
const result = await this.runRawSQL(infoQuery);
|
|
168
175
|
await this.schemaFromResult(result, structDef);
|
|
@@ -234,9 +241,7 @@ class MySQLConnection extends connection_1.BaseConnection {
|
|
|
234
241
|
if (!metadata) {
|
|
235
242
|
return jsonArray;
|
|
236
243
|
}
|
|
237
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
238
244
|
const filteredArray = jsonArray
|
|
239
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
245
|
.filter(
|
|
241
246
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
242
247
|
(element) => element !== null && !MySQLConnection.checkIsMalloyMetadata(element))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-mysql",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.392",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,12 +17,13 @@
|
|
|
17
17
|
"lint-fix": "eslint '**/*.ts{,x}' --fix",
|
|
18
18
|
"test": "jest --config=../../jest.config.js",
|
|
19
19
|
"build": "tsc --build",
|
|
20
|
+
"dev": "tsc --build",
|
|
20
21
|
"clean": "tsc --build --clean && rm -f tsconfig.tsbuildinfo",
|
|
21
22
|
"malloyc": "ts-node ../../scripts/malloy-to-json",
|
|
22
23
|
"prepublishOnly": "npm run build"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
|
-
"@malloydata/malloy": "0.0.
|
|
26
|
+
"@malloydata/malloy": "0.0.392",
|
|
26
27
|
"@types/node": "^22.7.4",
|
|
27
28
|
"fastestsmallesttextencoderdecoder": "^1.0.22",
|
|
28
29
|
"luxon": "^3.5.0",
|