Commit Graph

3225 Commits

Author SHA1 Message Date
Diana Lau ac955826f5 4.11.0
* fix: prevent max listeners warning (Dominique Emond)
2019-08-09 13:23:25 -04:00
Nora a90dc0eac4
Merge pull request #1767 from strongloop/dremond_migrate_errors
fix: prevent max listeners warning
2019-08-09 09:18:38 -04:00
Dominique Emond bca631518b fix: prevent max listeners warning
If establishing a database connection is slow
and database migration runs and there are many
models, sql operations are queued up and this
leads to the node.js max emitters exceeded
warning.

A default value for max emitters has now
been introduced, and it can also be configured
in datasources.json.

Co-authored-by: Dominique Emond <dremond@ca.ibm.com>
2019-08-09 09:03:51 -04:00
Miroslav Bajtoš ad4edc6a15
4.10.1
* Fix coercion of PK value in `replaceById` method (Miroslav Bajtoš)
 * Fix autoupdate queueing automigrate instead (#1762) (darthmaim)
2019-07-26 09:22:59 +02:00
Miroslav Bajtoš 74c43ca358
Merge pull request #1763 from strongloop/fix/PK-coercion-in-replaceById
Fix coercion of PK value in `replaceById` method
2019-07-26 09:22:27 +02: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
darthmaim dd7167b533 Fix autoupdate queueing automigrate instead (#1762)
Fixes #1761
2019-07-25 14:17:34 -04:00
Miroslav Bajtoš ca4ede014e
4.10.0
* fix: use only promises for beginTransaction (Biniam Admikew)
 * feat: add DataSource.deleteAllModels() API (Miroslav Bajtoš)
2019-07-23 16:48:45 +02:00
Biniam Admikew 6b83b6f4d1
Merge pull request #1760 from strongloop/fix/begintransaction-api
fix: use only promises for beginTransaction
2019-07-19 11:11:58 -04:00
Biniam Admikew e3c276720f fix: use only promises for beginTransaction
Co-authored-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-07-19 10:30:10 -04:00
Miroslav Bajtoš 6478c73dde
Merge pull request #1759 from strongloop/feat/reset-datasource
feat: add DataSource.deleteAllModels() API
2019-07-18 18:22:37 +02:00
Miroslav Bajtoš 78c5b12740
feat: add DataSource.deleteAllModels() API
When writing tests, for performance reasons we often want to reuse
the same data-source instance for many tests suites. At the same time,
we want to keep such test suites independent and allow them to reuse
the same model name for different model classes.

Juggler does support redefinition of a model with the same name.

This change is adding a new API called that allows tests to remove all
old models before creating new ones. This API would be typically
called from a `before` hook.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-07-18 17:56:41 +02:00
Biniam Admikew 6aea50ad27 4.9.0
* fix: report errors from automigrate/autoupdate (Miroslav Bajtoš)
 * feat: add beginTransaction API on datasource (Biniam Admikew)
 * Revert "chore: expose beginTransaction API" (Biniam Admikew)
2019-07-15 17:27:53 -04:00
Miroslav Bajtoš 0c2bb81dac
Merge pull request #1756 from strongloop/fix/migrate-errors
fix: report errors from automigrate/autoupdate
2019-07-04 13:51:36 +02:00
Miroslav Bajtoš 40286fcd28
fix: report errors from automigrate/autoupdate
Defer automigrate/autoupdate until we are connected, so that connection
errors can be reported back to callers.

Fix postInit handler to not report connection error to console.log
and via dataSource "error" event in case there is already an operation
queued. When this happens, we want the error to be handled by the
queued operation and reported to its caller.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-07-04 12:36:50 +02:00
Biniam Admikew c3103a2077
Merge pull request #1753 from strongloop/feat/ds-begintransaction
add `beginTransaction` method to DataSource class
which calls `begin` method from the Transaction class
which in turn invokes the connector's `beginTransaction`
method if it supports transactions.
2019-06-28 15:06:49 -04:00
Biniam Admikew 1ed385e393 feat: add beginTransaction API on datasource
add beginTransaction method which calls begin
method from the Transaction class which in turn
calls the connector's beginTransaction method if
it supports transactions.

Co-Authored-By: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-06-28 12:58:50 -04:00
Biniam Admikew 39555a010a Revert "chore: expose beginTransaction API"
This reverts commit 313925a5e7.
2019-06-25 09:08:11 -04:00
Biniam Admikew 85a29caaa5 4.8.2
* chore: expose beginTransaction API (Biniam Admikew)
 * update LTS in README (#1751) (Diana Lau)
2019-06-24 22:48:21 -04:00
Biniam Admikew 5539ef7ac6
Merge pull request #1752 from strongloop/update/ds-declaration-file
chore: add beginTransaction API to declaration file
2019-06-24 18:06:46 -04:00
Biniam Admikew 313925a5e7 chore: expose beginTransaction API 2019-06-24 17:16:31 -04:00
Diana Lau 612cf05fdf
update LTS in README (#1751) 2019-06-21 21:15:56 -04:00
jannyHou 19e7a47489 4.8.1
* test: add property index to support cloudant (#1750) (Janny)
2019-06-20 11:43:46 -04:00
Janny 58b3c4f148
test: add property index to support cloudant (#1750) 2019-06-19 14:36:48 -04:00
Miroslav Bajtoš d49774c590
4.8.0
* Fix types to describe native Promise (Miroslav Bajtoš)
 * feat: after operation hook in case of errors (spurreiter)
 * Fix for #1724 - Added options to attribute updates (#1725) (Bill Matson)
2019-06-13 15:38:11 +02:00
Miroslav Bajtoš 5fcad43aab
Merge pull request #1749 from strongloop/fix/typings
Fix types to describe native Promise
2019-06-13 15:37:40 +02:00
Miroslav Bajtoš df4d89279a
Fix types to describe native Promise
In version 4.0.0, we switched from Bluebird to native Promises.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-06-13 15:24:01 +02:00
Miroslav Bajtoš acb667b73d
Merge pull request #1694 from spurreiter/operation-hook-error
feat: call after operation hook in case of errors
2019-06-01 11:33:53 +02:00
spurreiter 5b44c08f7a feat: after operation hook in case of errors
fix: move error into context

review: add debug statement; rename fns

fix: call next instead of ctx.end
2019-05-31 17:12:42 +02:00
Bill Matson 04523260c2 Fix for #1724 - Added options to attribute updates (#1725)
* Fix for #1724 - Added options to attribute updates

* Fix for #1724 - Added unit tests for options
2019-05-27 09:49:46 -04:00
Miroslav Bajtoš a5ba7408ff
4.7.1
* Fix "access" hook for unoptimized "near" queries (Miroslav Bajtoš)
 * Fix "loaded" hook for unoptimized "near" queries (Miroslav Bajtoš)
 * Test "near" queries executed in memory (Miroslav Bajtoš)
 * Fix DateString ctor to accept DateString instances (Miroslav Bajtoš)
 * datasource: copy settings object in constructor (Miroslav Bajtoš)
 * chore: update copyrights years (#1737) (Agnes Lin)
 * chore: update LTS status (#1734) (Diana Lau)
2019-05-14 09:48:27 +02:00
Miroslav Bajtoš 413f31631e
Merge pull request #1739 from strongloop/fix/hooks-with-near-queries
Fix implementation of Operation Hooks for "near" (geo) queries
2019-05-14 09:26:16 +02:00
Miroslav Bajtoš aa20180c4f
Fix "access" hook for unoptimized "near" queries
Before this change, when an "access" hook modified the "query" object,
the "near" condition from the original "query" object were still
applied. As a result, the query can end up being more restrictive and
return only a subset of models that should have matched the conditions.

With this change in place, after "access" hook observers are invoked,
we update the "near" condition using the "query" object provided by
hook observers.

Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-05-14 09:17:54 +02:00
Miroslav Bajtoš 344441d48d
Fix "loaded" hook for unoptimized "near" queries
Before this change, two "loaded" events were emitted for every model
instance found. This commit fixes the problem and restores the intended
behavior.

The bug was probably introduced by 5e0c73bec7.
2019-05-14 09:17:54 +02:00
Miroslav Bajtoš caf9d09274
Test "near" queries executed in memory
Rework setup of the Operation Hooks test suite for memory connector
so that the "unoptimized" variant disables not only atomic CRUD
operations, but also geo queries.

This way we can test both "near" querying implementations:
 - When the connectors supports "near" queries natively.
 - When "near" queries are executed at LoopBack side in-memory.
2019-05-14 09:14:10 +02:00
Miroslav Bajtoš 853a41641b
Merge pull request #1740 from strongloop/fix/datestring-ctor
Fix DateString constructor to accept DateString instances
2019-05-13 16:07:40 +02:00
Miroslav Bajtoš 5369cf3d54
Fix DateString ctor to accept DateString instances
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-05-13 15:21:00 +02:00
Miroslav Bajtoš 91ab3e9162
Merge pull request #1738 from strongloop/fix/modification-of-datasource-config
datasource: copy settings object in constructor
2019-05-10 16:01:39 +02:00
Miroslav Bajtoš ef0257e338
datasource: copy settings object in constructor
Fix DataSource constructor to create a shallow copy of the settings
object provided by the caller. This prevents surprising behavior
where changes made to `ds.settings` were picked up by the provided
config object, as observed e.g. in tests of our MongoDB connector.
2019-05-10 14:56:02 +02:00
Agnes Lin de4718d5b8 chore: update copyrights years (#1737) 2019-05-08 11:45:37 -04:00
Diana Lau 98eb783a80
chore: update LTS status (#1734) 2019-05-06 13:27:52 -04:00
biniam 2aa4d20394 4.7.0
* fix: allow coercion of nested properties (biniam)
2019-05-03 19:15:10 -04:00
Biniam Admikew 0b871d1de1
Merge pull request #1727 from strongloop/fix/nested-property-coercion-4x
fix: allow coercion of nested properties

Handle model definitions with nested property
definitions for coercion of primitive values.
2019-05-03 19:08:53 -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š 3fba79e725
4.6.4
* Fix tests for empty/default values to pass on SQL (Miroslav Bajtoš)
 * Update nyc to 14.0.0 (Miroslav Bajtoš)
 * test: define models in before hooks (biniam)
 * Update `should` to `13.2.3` (Miroslav Bajtoš)
 * Update `mocha` to `6.1.4` (Miroslav Bajtoš)
2019-05-03 09:04:42 +02:00
Miroslav Bajtoš 78c4bfbc2d
Merge pull request #1733 from strongloop/fix/postgresql
Fix tests for empty vs. default values to pass on SQL
2019-05-03 09:04:08 +02:00
Miroslav Bajtoš b0e3de1083
Fix tests for empty/default values to pass on SQL 2019-05-03 08:57:48 +02:00
Miroslav Bajtoš 08e8725ba5
Merge pull request #1732 from strongloop/update-nyc
Update nyc to 14.0.0
2019-05-02 13:24:58 +02:00
Miroslav Bajtoš 837c74d08e
Update nyc to 14.0.0 2019-05-02 13:01:10 +02:00
Biniam Admikew 6677c58cff
Merge pull request #1721 from strongloop/fix/failing-tests
test: define models properly
2019-04-30 11:50:10 -04:00