Commit Graph

826 Commits

Author SHA1 Message Date
Janny 2190f2510f Backport - Apply hasManyThrough filter on target model (#1404)
* Apply hasManyThrough filter on target model

* Compatible with mongodb
2017-06-22 16:51:10 -04:00
Candy 3e02e36314 Fix assert as array does not guarantee order 2017-05-05 16:14:17 -04:00
Matteo Padovano 93b89f3a51 remove equality value for user-defined id (#1292)
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 13:15:19 -04:00
Matteo Padovano 570da781b8 override collection name for arangodb (#1274)
Add collection name settings for arangodb database.
Required to pass common tests included in community connector
2017-03-25 18:22:59 -04:00
Miroslav Bajtoš af1d959613 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-06 10:58:44 +01:00
Miroslav Bajtoš 5492e59207 Add two basic tests for "inq" operator 2017-01-20 13:04:28 +01:00
Heath Morrison c62ba21307 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 15:11:20 +01:00
Brian Schemp d87e3bf8fb 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-03 10:41:07 +01:00
Miroslav Bajtoš f8da9783bc Back-port fixes for linter errors from master 2016-12-06 10:47:27 +01:00
Amir Jafarian 69ce75c662 Apply style guide to test names
*  Apply style guide to test names in test/loopback-dl.test.js
Backport of #1150
2016-10-27 18:02:26 -04:00
Heath Morrison 552dfc8f24 Continue _coerce after logical operators 2016-10-26 10:14:43 -04:00
Amir Jafarian e038b28e8c Fix manually 2016-10-19 17:35:26 -04:00
Amir Jafarian a1683fca59 Auto-update by eslint --fix 2016-10-19 17:04:05 -04:00
Miroslav Bajtoš 70a1552df8 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 12:33:21 +02:00
Amirali Jafarian 8caf4c8327 Merge pull request #1108 from strongloop/fix_geo_2.x
Fix the bug when near filter is used
2016-10-13 10:39:15 -04:00
Simon Ho c3eca4025c Support {defaultFn: 'shortid'} (#1110)
- Backport of strongloop/loopback-datasource-juggler#1107 (takeover of
strongloop/loopback-datasource-juggler#1101)
- Squashed relevant commits
2016-10-12 20:58:07 -07:00
Simon Ho a9d381605e Add ilike and nilike operators (#1136)
Closes #633

Backport of #1091
2016-10-12 19:19:31 -07:00
Amir Jafarian fde4c0bfd6 Fix bug when near filter is used 2016-10-11 17:08:42 -04:00
Amir Jafarian e103b50b63 Add 'isNewInstance' for updateAttributes
* Add 'isNewInstance' to loaded hook for updateAttes
2016-09-23 14:09:44 -04:00
Loay d324696d2a Skip test temporarily 2016-09-14 22:23:24 -04:00
Miroslav Bajtoš f663917fe9 Add missing "done" arg in test/kvao/ttl.suite
Backport #1086
2016-09-08 10:39:47 +02:00
pponugo 64a9b8d506 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:20:56 +02:00
Simon Ho 95bc2e93cc Remove expired item before executing expire
The expire feature is falsely returning 204 instead of 404 because it is
not removing expired items before execution.
2016-09-06 16:04:33 -07:00
Amir Jafarian 12aadd4266 Fix failures for connectors 2016-09-06 13:41:50 -04:00
Sonali Samantaray 44e1d29879 upsertWithWhere feature support in juggler DAO
Backport from #1001
2016-09-06 13:41:50 -04:00
Simon Ho cf432fceec Refactor TTL test suite 2016-09-03 11:36:28 -07:00
Miroslav Bajtoš 65c8ec41e0 test/memory: remove dummy findOrCreate impl
Let the operation-hook tests use the real implementation,
now that we have it in place.
2016-08-26 09:53:19 +02:00
Amir Jafarian a1a9bac9ba Implement `notify` for find method 2016-08-23 19:00:50 -04:00
Miroslav Bajtoš ab47ecfbab kvao: implement key filter 2016-08-18 10:30:55 +02:00
Miroslav Bajtoš 24a9a96a26 kvao: add iterateKeys() and keys()
Add a core implementation of KVAO.iterateKeys() which returns an
AsyncIterator, inspired by
 - https://github.com/tc39/proposal-async-iteration
 - https://www.npmjs.com/package/async-iterators

This way we can safely iterate even large sets of data.

Also add KVAO.keys(), a sugar API converting the result of iterateKeys()
into a single array.
2016-08-18 10:30:53 +02:00
Simon Ho 5001a98135 test: Rename KVAO get test suite
[back-port of #2591]
2016-08-16 09:47:23 -07:00
Miroslav Bajtoš df4a3643eb Merge pull request #1044 from strongloop/fix/kvao-promise
test/kvao: setup global.Promise on Node v0.10 [2.x only]
2016-08-15 14:05:20 +02:00
Simon Ho 421597c998 Add TTL for KeyValue related features
Backport of strongloop/loopback-datasource-juggler#1030
2016-08-12 14:49:01 -07:00
Miroslav Bajtoš 9d0d41d660 test/kvao: setup global.Promise on Node v0.10
When running the tests on Node v0.10, setup `global.Promise`
with Bluebird implementation. That way we don't have to run
this setup in the test suite of each kv connector.
2016-08-12 16:34:26 +02:00
Miroslav Bajtoš 1750583a15 kv-memory: fix crash in regular cleanup
Fix bug in "_setupRegularCleanup()" where the interval callback
was trying to access an object that has been garbage-collected
in the meantime.
2016-08-10 14:19:05 +02:00
Miroslav Bajtoš 8013b6acd4 kvao: return 404 when expiring unknown key 2016-08-09 10:47:12 +02:00
Miroslav Bajtoš 837f58f82d Implement KeyValue API and memory connector
Models attached to a KeyValue connector get the following *static*
methods:

    Color.set(key, value);
    Color.set(key, value, ttl);
    Color.set(key, value, { ttl: ttl });

    Color.get(key);

    Color.expire(key, ttl);
2016-08-08 14:48:04 +02:00
Amir Jafarian 5a594d4855 Fix test case typo
Backport loopback-datasource-juggler#1016
2016-07-24 09:05:33 -04:00
Amir Jafarian 6efd00698b Add test for updateOrCreate
* Add test for updateOrCreate when id is not autogenerated Id
Backport loopback-datasource-juggler#989
2016-07-23 11:25:38 -04:00
Supasate Choochaisri f1a70094fa Add test to catch invalid date property
Signed-off-by: Supasate Choochaisri <supasate.c@gmail.com>
See https://github.com/strongloop/loopback-datasource-juggler/pull/1000
2016-07-15 10:47:44 -07:00
Miroslav Bajtoš ebcb5a0546 Ensure stable order of items in DAO.find()
When post-processing result of find operation, use "async.map"
instead of "async.each + array.push" to ensure the order of items
is preserved.
2016-07-13 15:25:34 +02:00
Raymond Feng 6736d72b98 Merge pull request #986 from robinbiondi/postgresConcurency
Fix #984 Give request options(ex: transactions) to validators
2016-06-24 14:42:50 -07:00
RobinBiondi 35f14c38dc give options to validators #984 2016-06-24 22:04:35 +02:00
Amir Jafarian 26718c733a Give warning if PK is changed in hooks
* Give warning if PK is changed in `before save` and `loaded`
 operation hooks for replaceById
2016-06-08 15:54:22 -04:00
Dimitris Halatsis af8cf19242 Persist changes on parent for embedsOne
Allow direct save of changes on embedded model to be persisted on
parent document.

    Person.embedsOne(Address);
    Person.findById(someId)
      .then(function(p){
        var address = p.addressItem();
        address.street = 'new street'
        // This will now persist changes on parent document
        return address.save();
      })
2016-06-07 17:09:34 +02:00
Miroslav Bajtoš 9bf60e0d74 fix 2016-06-03 16:29:39 -04:00
Amir-61 7aa9cb357d Merge pull request #959 from strongloop/fix_err_msg
Fix error message
2016-06-01 21:00:26 -04:00
Amir Jafarian c093648525 Fix error message
* Fix error message when PK is changed in `replaceById`
2016-06-01 16:26:41 -04:00
Amir Jafarian 05ea5467cd Add test's description 2016-06-01 16:05:56 -04:00
Dimitris Halatsis 39907c6421 ModelBuilder: add new setting strictEmbeddedModels
The setting controls the strict mode used for embedded property types,
for example the type of "address" property in this model definition:

    modelBuilder.define('TestEmbedded', {
      name: 'string',
      address: {
        street: 'string',
      },
    });

[back-port of #955]
2016-06-01 13:42:55 +02:00