Commit Graph

124 Commits

Author SHA1 Message Date
Mario Estrada e3448fad03 chore: replace shortid with nanoid
Signed-off-by: Mario Estrada <marioestradarosa@yahoo.com>
2021-09-12 18:14:03 +08:00
Matteo Padovano 76acf333fd
chore: add test for atomic upsertWithWhere (#1864)
Introduce the new property atomicUpsertWithWhere for
connector that implement specific method.
See https://github.com/strongloop/loopback-connector-mongodb/pull/563
for mongodb implementation.

Signed-off-by: Matteo Padovano <mrbatista@users.noreply.github.com>
2020-09-25 10:22:03 -04:00
Miroslav Bajtoš 1b7858a857
chore: update eslint to 6.x
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-12-03 10:09:16 +01:00
Dimitris Xalatsis b30fbf8c1e return failed promise on error 2019-11-22 19:38:43 +02:00
Francisco Buceta b9f0284a28
Fix generated string id's
Co-authored-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-11-15 16:15:38 +01:00
Miroslav Bajtoš f1fa976f50
Fix coercion of PK value in `replaceById` method
Before this change, when both the PK value (`id`) and the `data` object
were provided as plain-data values (e.g. as received in a JSON request),
and the connector was using a complex PK type (e.g. `ObjectID`
in MongoDB), then `replaceById` operation was printing confusing
warnings:

    WARNING: id property cannot be changed from 5d39775a59f5f541513c5e05
        to 5d39775a59f5f541513c5e05 for model:Post
        in 'before save' operation hook

    WARNING: id property cannot be changed from 5d39775a59f5f541513c5e05
        to 5d39775a59f5f541513c5e05 for model:Post
        in 'loaded' operation hook

This commit fixes the problem by applying the same type coercion on the
PK value (`id`) as has been applied by the model constructor on the PK
property (`data.id`).

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-07-26 09:02:52 +02:00
Agnes Lin de4718d5b8 chore: update copyrights years (#1737) 2019-05-08 11:45:37 -04:00
biniam 9c94b9344b fix: allow coercion of nested properties
Handle model definitions with nested property
definitions for coercion of primitive values.
2019-05-03 18:45:39 -04:00
Miroslav Bajtoš b0e3de1083
Fix tests for empty/default values to pass on SQL 2019-05-03 08:57:48 +02:00
biniam 48af738ec4 fix: coerce primitive properties on update 2019-04-16 10:51:44 -04:00
Miroslav Bajtoš 7d69bdab70
Improve tests for empty vs. default values 2019-04-09 15:54:52 +02:00
Miroslav Bajtoš e45292de08
Do not apply default values on data from database
Before this change, when a property was configured with a default value
at LoopBack side and the database was returned a record with a missing
value for such property, then we would supply use the configured
default.

This behavior is problematic for reasons explained in #1692.

In this commit, we are fixing DAO operations like `find` and
`findOrCreate` so that they do NOT apply default property values on
data returned by the database (connector).

Please note that most of the other CRUD methods were already not
applying default values on database data as long as the connector
provided native implementation of the operation.
2019-04-04 09:47:31 +02:00
Miroslav Bajtoš 9e0f624ad5
manually fix remaining problems 2018-12-07 16:46:15 +01:00
Miroslav Bajtoš 422ec9ad4f
autofix eslint errors 2018-12-07 16:46:15 +01:00
Tom Kirkpatrick 251798c711 fix: ignore extra properties when strict=filter (#1423)
Fix for #1422
2018-08-29 22:57:37 -04:00
Miroslav Bajtoš 7d50f6130b
Upgrade eslint-config-loopback + fix formatting
The new version of our config enabled function-paren-newline rule,
this commit fixes the codebase to use more consistent handling
of newlines when calling functions.
2018-07-16 08:46:25 +02:00
shenghu bc16692d9b assertation of undefined could be null 2018-07-09 11:53:27 -04:00
Miroslav Bajtoš d2ee73b9d3
Update eslint + config to latest 2018-06-12 09:13:32 +02:00
loay 01b4c4a3a7 Catch err using Callback 2017-08-16 17:00:41 -04:00
ssh24 80f015c2d2 Honor backwards compatability with validate update 2017-08-03 11:50:44 -04:00
ssh24 b1a0cb8c3b Validate updateAll 2017-08-02 13:24:21 -04:00
loay b1b2d5df0c Catch errors using cb 2017-07-24 14:08:58 -04:00
Janny 6a1b55568c Skip imcompatible tests (#1420)
* Skip imcompatible tests
2017-07-18 15:20:21 -04:00
Janny b9129e6973 Run juggler tests for Cloudant (#1414) 2017-07-11 14:56:39 -04:00
Raymond Feng 5a0b0270f3 Return promise for batch create 2017-05-19 16:16:52 -07:00
Loay 87dd44dd59 Fix assertion errors 2017-05-04 10:38:06 -04:00
Diana Lau a488a71dbd replace exception thrown for invalid dates 2017-04-21 15:57:11 -04:00
Loay 3c19beacbb Add test case using updateAttributes 2017-04-18 13:50:57 -04:00
Loay f1d10b47ce Fix forceId bug for updateOrCreate 2017-04-18 13:14:35 -04:00
Loay 9dc5430652 Unskip test case 2017-04-12 12:54:30 -04:00
Tetsuo Seto ead1fb2965 Add test support for Cassandra connector 2017-04-07 11:10:47 -07:00
Matteo Padovano 957058e2d4 remove equality value for user defined id (#1293)
Some connector, like arangodb, not support id as Number.
When `forceId` is set to true and id is set `Model.isValid`
report error and the field id is not coerced.
2017-04-04 12:45:23 -04:00
Kevin Delisle a6c5802940 dao: catch sync errors on setAttributes
Wrap inst.setAttributes in try-catch to prevent synchronous errors
from crashing the application.
2017-03-16 17:26:53 -04:00
Loay 4bd03a25f2 Ensure replaceById returns 404 when id not found 2017-02-01 11:57:54 -05:00
Loay 44a5a7ad81 Fix forceId validation error 2017-01-26 16:52:19 -05:00
Miroslav Bajtoš 454bf93aaf Upgrade eslint-config to 7.x
Also upgrade eslint itself to 3.x.
2017-01-06 13:33:54 +01:00
Siddhi Pai 3baa61590e Fix block padding
* Remove test/.eslintrc
* run eslint . --fix
2016-12-13 16:05:50 -08:00
Miroslav Bajtoš 0f7a567f18 Upgrade eslint & config to latest
- eslint ^3.11.1
 - eslint-config-loopback: ^6.0.0
 - fix linter errors (mostly no-undef)
2016-12-05 15:14:09 +01:00
Amir Jafarian e391fd0f3e Tests cleanup
* Tests cleanup for `manipulation.test` and `scope.test`
2016-11-29 10:45:03 -05:00
Amir Jafarian fab269687b Correct tests for DAO.Create
* Create does not return data back
2016-11-28 17:18:10 -05:00
Simon Ho 06d4b90071 Add code review fixups 2016-09-22 16:15:32 -07:00
Tim De Pauw 5636c15903 More descriptive name for model with shortid 2016-09-22 16:07:34 -07:00
Tim De Pauw 419a464d06 Polish PR 2016-09-22 16:07:34 -07:00
Tim De Pauw be1d71f626 Support {defaultFn: 'shortid'} 2016-09-22 16:07:34 -07:00
David Cheung 805db78e19 Strict mode now always return validationError
- Deprecation of strict:validate and strict:throw
- When strict mode is enabled, it will now always
return validation error (previous strict:validate)
2016-09-19 10:27:24 -04:00
Loay 32a6b68f1d Skip test temporarily 2016-09-09 14:48:41 -04:00
Simon Ho 11ce971ad0 Fix BSON Object ID errors for CI 2016-09-08 13:16:55 -07:00
Amir Jafarian 581b8c61bf Fix failures of upsertWithWhere
Forwardport of #1052
2016-09-02 15:46:36 -04:00
Amir Jafarian aec678d252 Fix manually 2016-08-22 19:20:12 -04:00
Amir Jafarian aa6d28268b Auto-update by eslint --fix 2016-08-22 15:12:25 -04:00