Commit Graph

881 Commits

Author SHA1 Message Date
jannyHou 8b1100e3ed Add test case for all connectors 2017-02-14 14:01:44 -05:00
Loay 9541bb5f15 Add proper statusCode for duplicate 2017-02-08 23:52:14 -05:00
Miroslav Bajtoš e8a977f55b Fix datasource to report connector-loading errors
Before this change, when resolving full connector path, all errors were
ignored. As a result, when the connector was installed but not
correctly built (e.g. loopback-connector-db2 which uses a native addon),
a very confusing message was reported by LoopBack.

In this commit, I am fixing the code handling `require()` errors
to ignore only MODULE_NOT_FOUND errors that contain the name
of the required module.
2017-02-03 20:29:11 +01:00
Loay 4bd03a25f2 Ensure replaceById returns 404 when id not found 2017-02-01 11:57:54 -05:00
Miroslav Bajtoš d809260799 Upgrade eslint-config, fix new violations 2017-02-01 12:45:56 +01:00
Matteo Padovano 733ad1a024 Refactor logic of options.allowExtendedOperators
Implement logic to allowExtendedOperators options
per request, per Model and Datasource.
2017-01-30 00:05:56 +01:00
Loay 44a5a7ad81 Fix forceId validation error 2017-01-26 16:52:19 -05:00
Miroslav Bajtoš b5d03b845f Add two basic tests for "inq" operator 2017-01-19 13:33:39 +01:00
Simon Ho 9a0d34a7a3 Add missing return for KVAO delete all 2017-01-13 00:19:10 -08:00
Simon Ho 188fb10c96 Add missing return in KVAO keys test suite 2017-01-11 19:35:37 -08:00
Simon Ho 0b93c5c6dd Detect deleteAll support in KVAO tests
Clear CacheItem data between tests if connector supports `deleteAll`.
Tests fail with 501 if this check is not used.
2017-01-11 16:30:33 -08:00
Heath Morrison 2377792c22 Coerce array-like objects into arrays
The query-string parser used by express
https://github.com/ljharb/qs#parsing-arrays
limits the size of arrays that are created from query strings to 20
items. Arrays larger than that are converted to objects using numeric
indices.

This commit fixes the coercion algorithm used by queries to
treat number-indexed objects as arrays. We still maintain a strict
understanding of an "array-like object" to limit the opportunity for
subtle bugs. In particular, the presence of non-index keys is an
indication that the object was not intended to be interpreted as
an array.
2017-01-10 14:46:41 +01:00
Simon Ho 2320df1227 Refactor flush to deleteAll
- Rename `flush` to `deleteAll`
- Add `delete`
- Detect `delete/deleteAll` before running downstream test suites
- Fall back to unoptimized `deleteAll` when connector does not support
  `deleteAll` but supports `delete`
- Return 501 for connectors not supporting `delete` or `deleteAll`
2017-01-09 14:53:34 -08: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
Brian Schemp cd94be2fb8 Throw error when model relation name is trigger
Defining a model relation with the name "trigger" causes the model not
able to insert records. No error is thrown when a model relation with
the name "trigger" is defined. Adding a check for the model relation
name "trigger" will now throw an error.
2017-01-02 17:09:14 +01:00
Simon Ho f38709b7cb Add flush operation to KVAO
Used to delete all keys (and values) associated to the current model.
2016-12-30 18:06:36 -08:00
Simon Ho d095cc1161 Merge pull request #1194 from strongloop/1237/fix-block-padding
Fix block padding
2016-12-21 14:17:42 -08:00
Miroslav Bajtoš 2ca081216b Fix eslint errors reported by the latest eslint 2016-12-20 17:37:54 +01:00
Siddhi Pai 3baa61590e Fix block padding
* Remove test/.eslintrc
* run eslint . --fix
2016-12-13 16:05:50 -08:00
Simon Ho c5e905f5c4 Fix linter errors for CI 2016-12-09 18:13:58 -08:00
Miroslav Bajtoš 779cf6a370 Honour allowExtendedOperators in "DAO.find"
Modify the coercion of filter.where to hounour "allowExtendedOperators"
and don't coerce property values of type object (extended operators).
2016-12-06 10:28:40 +01:00
Miroslav Bajtoš 80d2264bc9 Merge pull request #1179 from strongloop/update/eslint
Upgrade eslint & config to latest
2016-12-06 10:12:11 +01:00
Loay e14c48719e Fix MySql CI server Failure 2016-12-05 11:42:08 -05: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
jannyHou 6c8e806bc8 Apply hasManyThrough filter on target model 2016-12-01 10:08:27 -05: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
Amir Jafarian d908a52753 Fix a test
* Fix location for an instance in a test
2016-10-30 20:50:06 -04:00
Amir Jafarian 756e936c4b Add more robust OH tests for find method 2016-10-28 16:56:38 -04:00
Amir Jafarian 54d0f5b53d Add support for `loaded` hook
* Add support for loaded hook for DAO.find with near filter
2016-10-28 11:46:46 -04:00
Amir Jafarian a65311dc7c Use imperative mood for tests
* Use imperative mood for tests in test/loopback-dl.test.js
2016-10-27 16:38:40 -04:00
Heath Morrison 266e9f5a9a Continue _coerce after logical operators 2016-10-25 23:09:46 +03:00
Amir Jafarian 212e9b1f85 Make variable names more clear
* Fix up #1109
2016-10-21 17:26:39 -04:00
Amirali Jafarian d9a736a4a8 Merge pull request #1109 from C3realGuy/dev_validations
validateNumericality should skip undefined
2016-10-20 07:37:52 -04:00
Miroslav Bajtoš 011bfbb236 test/kvao: add connectorCapabilities options
- canExpire
 - canQueryTtl
 - ttlPrecision
 - canIterateKeys
 - canIterateLargeKeySets

These options allow connectors to disable shared tests for features
that are not supported/implemented.
2016-10-19 11:06:17 +02:00
CerealGuy 662458dc2c Fix validateNumericality, nullCheck & add tests
validateNumericality didn't test if attributes value is a number
only if it's type is number.
Further nullCheck had a wrong testing order. It first checked if
value is null, later if blank. Also null check only used two equals,
not three. We don't use blank() anymore, testing if variable is
undefined should be fine too.
Added tests covering validateNumericality.
2016-10-15 10:59:22 +02:00
Amir Jafarian f5e9b53289 Add test for operation hooks
* Add test for operation hook when near filter is used
2016-10-14 09:23:26 -04:00
Nick Duffy a23076d3a8 Add ilike and nilike operators
Closes #633
2016-10-12 18:31:31 -06:00
Loay 2cb0d042e4 Fix CI Failures in MySQL 2016-09-26 20:27:33 -04: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
Amirali Jafarian 66f27b9b83 Merge pull request #1094 from strongloop/newInstance_loade_updateAttributes
Add 'isNewInstance' for updateAttributes
2016-09-21 09:23:57 -04:00
Amir Jafarian fec7742a69 Add 'isNewInstance' for updateAttributes
* Add 'isNewInstance' to loaded hook for updateAttributes
2016-09-19 16:56:15 -04: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
Miroslav Bajtoš a438c72cc5 Add missing "done" arg in test/kvao/ttl.suite 2016-09-08 10:22:27 +02:00
pponugo a39c0236bb Support nested queries for arrays
Enhance the built-in memory connector to correctly support nested
queries for arrays in addition to objects.

E.g. if "friends" is an array of objects containing "name", then
{ where: { "friends.name": "Jane" } } should match records containing
a friend called "Jane".
2016-09-07 13:33:57 +02:00