@platformatic/sql-mapper 1.15.1 → 1.17.0
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/mapper.js +18 -1
- package/package.json +12 -10
- package/.taprc +0 -1
package/mapper.js
CHANGED
|
@@ -101,7 +101,7 @@ async function createConnectionPool ({ log, connectionString, poolSize, idleTime
|
|
|
101
101
|
return { db, sql }
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
async function connect ({ connectionString, log, onDatabaseLoad, poolSize, ignore = {}, autoTimestamp = true, hooks = {}, schema, limit = {}, dbschema, cache, idleTimeoutMilliseconds, queueTimeoutMilliseconds, acquireLockTimeoutMilliseconds }) {
|
|
104
|
+
async function connect ({ connectionString, log, onDatabaseLoad, poolSize, include = {}, ignore = {}, autoTimestamp = true, hooks = {}, schema, limit = {}, dbschema, cache, idleTimeoutMilliseconds, queueTimeoutMilliseconds, acquireLockTimeoutMilliseconds }) {
|
|
105
105
|
if (typeof autoTimestamp === 'boolean' && autoTimestamp === true) {
|
|
106
106
|
autoTimestamp = defaultAutoTimestampFields
|
|
107
107
|
}
|
|
@@ -164,6 +164,19 @@ async function connect ({ connectionString, log, onDatabaseLoad, poolSize, ignor
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
const schemaTables = dbschema.map(table => table.table)
|
|
167
|
+
if (Object.keys(include).length) {
|
|
168
|
+
for (const includedTable of Object.keys(include)) {
|
|
169
|
+
if (!schemaTables.includes(includedTable)) {
|
|
170
|
+
const nearestTable = findNearestString(schemaTables, includedTable)
|
|
171
|
+
let warningMessage = `Specified table "${includedTable}" not found.`
|
|
172
|
+
if (nearestTable) {
|
|
173
|
+
warningMessage += ` Did you mean "${nearestTable}"?`
|
|
174
|
+
}
|
|
175
|
+
log.warn(warningMessage)
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
167
180
|
for (const ignoredTable of Object.keys(ignore)) {
|
|
168
181
|
if (!schemaTables.includes(ignoredTable)) {
|
|
169
182
|
const nearestTable = findNearestString(schemaTables, ignoredTable)
|
|
@@ -182,6 +195,10 @@ async function connect ({ connectionString, log, onDatabaseLoad, poolSize, ignor
|
|
|
182
195
|
if (typeof table !== 'string') {
|
|
183
196
|
throw new errors.TableMustBeAStringError(table)
|
|
184
197
|
}
|
|
198
|
+
// If include is being used and a table is not explicitly included add it to the ignore object
|
|
199
|
+
if (Object.keys(include).length && !include[table]) {
|
|
200
|
+
ignore[table] = true
|
|
201
|
+
}
|
|
185
202
|
if (ignore[table] === true) {
|
|
186
203
|
continue
|
|
187
204
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-mapper",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "A data mapper utility for SQL databases",
|
|
5
5
|
"main": "mapper.js",
|
|
6
6
|
"types": "mapper.d.ts",
|
|
@@ -15,11 +15,12 @@
|
|
|
15
15
|
},
|
|
16
16
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
17
17
|
"devDependencies": {
|
|
18
|
+
"@matteo.collina/tspl": "^0.1.0",
|
|
18
19
|
"fastify": "^4.23.2",
|
|
20
|
+
"glob": "^10.3.10",
|
|
19
21
|
"snazzy": "^9.0.0",
|
|
20
22
|
"standard": "^17.1.0",
|
|
21
|
-
"
|
|
22
|
-
"tsd": "^0.29.0"
|
|
23
|
+
"tsd": "^0.30.0"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@databases/mysql": "^6.0.0",
|
|
@@ -32,19 +33,20 @@
|
|
|
32
33
|
"camelcase": "^6.3.0",
|
|
33
34
|
"fastify-plugin": "^4.5.1",
|
|
34
35
|
"inflected": "^2.1.0",
|
|
35
|
-
"@platformatic/utils": "1.
|
|
36
|
+
"@platformatic/utils": "1.17.0"
|
|
36
37
|
},
|
|
37
38
|
"tsd": {
|
|
38
39
|
"directory": "test/types"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"lint": "standard | snazzy",
|
|
42
|
-
"test": "
|
|
43
|
-
"test:
|
|
44
|
-
"test:
|
|
45
|
-
"test:
|
|
46
|
-
"test:
|
|
47
|
-
"test:
|
|
43
|
+
"test": "npm run lint && npm run test:typescript && npm run test:postgresql && npm run test:mariadb && npm run test:mysql && npm run test:mysql8 && npm run test:sqlite",
|
|
44
|
+
"test:runner": "node ./test/runner.js",
|
|
45
|
+
"test:postgresql": "DB=postgresql npm run test:runner",
|
|
46
|
+
"test:mariadb": "DB=mariadb npm run test:runner",
|
|
47
|
+
"test:mysql": "DB=mysql npm run test:runner",
|
|
48
|
+
"test:mysql8": "DB=mysql8 npm run test:runner",
|
|
49
|
+
"test:sqlite": "DB=sqlite npm run test:runner",
|
|
48
50
|
"test:typescript": "tsd"
|
|
49
51
|
}
|
|
50
52
|
}
|
package/.taprc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
jobs: 1
|