@platformatic/sql-mapper 1.36.0 → 1.36.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/lib/entity.js +5 -2
- package/lib/errors.js +1 -0
- package/package.json +3 -3
package/lib/entity.js
CHANGED
|
@@ -149,11 +149,14 @@ function createMapper (defaultDb, sql, log, table, fields, primaryKeys, relation
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
async function updateMany (args) {
|
|
152
|
-
const db = args.tx || defaultDb
|
|
153
|
-
const fieldsToRetrieve = computeFields(args.fields).map((f) => sql.ident(f))
|
|
154
152
|
if (args.input === undefined) {
|
|
155
153
|
throw new errors.InputNotProvidedError()
|
|
156
154
|
}
|
|
155
|
+
if (args.where === undefined || Object.keys(args.where).length === 0) {
|
|
156
|
+
throw new errors.MissingWhereClauseError()
|
|
157
|
+
}
|
|
158
|
+
const db = args.tx || defaultDb
|
|
159
|
+
const fieldsToRetrieve = computeFields(args.fields).map((f) => sql.ident(f))
|
|
157
160
|
const input = fixInput(args.input)
|
|
158
161
|
if (autoTimestamp && fields[autoTimestamp.updatedAt]) {
|
|
159
162
|
const now = new Date()
|
package/lib/errors.js
CHANGED
|
@@ -19,5 +19,6 @@ module.exports = {
|
|
|
19
19
|
ParamLimitNotAllowedError: createError(`${ERROR_PREFIX}_PARAM_LIMIT_NOT_ALLOWED`, 'Param limit=%s not allowed. Max accepted value %s.'),
|
|
20
20
|
ParamLimitMustBeNotNegativeError: createError(`${ERROR_PREFIX}_PARAM_LIMIT_MUST_BE_NOT_NEGATIVE`, 'Param limit=%s not allowed. It must be a not negative value.'),
|
|
21
21
|
MissingValueForPrimaryKeyError: createError(`${ERROR_PREFIX}_MISSING_VALUE_FOR_PRIMARY_KEY`, 'Missing value for primary key %s'),
|
|
22
|
+
MissingWhereClauseError: createError(`${ERROR_PREFIX}_MISSING_WHERE_CLAUSE`, 'Missing where clause', 400),
|
|
22
23
|
SQLiteOnlySupportsAutoIncrementOnOneColumnError: createError(`${ERROR_PREFIX}_SQLITE_ONLY_SUPPORTS_AUTO_INCREMENT_ON_ONE_COLUMN`, 'SQLite only supports autoIncrement on one column')
|
|
23
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-mapper",
|
|
3
|
-
"version": "1.36.
|
|
3
|
+
"version": "1.36.2",
|
|
4
4
|
"description": "A data mapper utility for SQL databases",
|
|
5
5
|
"main": "mapper.js",
|
|
6
6
|
"types": "mapper.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@matteo.collina/tspl": "^0.1.1",
|
|
19
|
-
"borp": "^0.
|
|
19
|
+
"borp": "^0.12.0",
|
|
20
20
|
"fastify": "^4.26.2",
|
|
21
21
|
"snazzy": "^9.0.0",
|
|
22
22
|
"standard": "^17.1.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"camelcase": "^6.3.0",
|
|
34
34
|
"fastify-plugin": "^4.5.1",
|
|
35
35
|
"inflected": "^2.1.0",
|
|
36
|
-
"@platformatic/utils": "1.36.
|
|
36
|
+
"@platformatic/utils": "1.36.2"
|
|
37
37
|
},
|
|
38
38
|
"tsd": {
|
|
39
39
|
"directory": "test/types"
|