Commit Graph

1021 Commits

Author SHA1 Message Date
Hage Yaapa 9979efd040 feat: added persistDefaultValues (#1815)
Ignores value if it matches default value.
2019-12-17 10:53:29 -05:00
Hage Yaapa f9a5c44dba feat: applyDefaultOnWrites in nested properties
Adds support for `applyDefaultOnWrites` in nested properties.
2019-12-12 20:25:29 +05:30
Dimitris Xalatsis 315545daa0 return failed promise on error (cherry-picked) 2019-11-29 18:12:49 +02:00
Dimitris Halatsis b925e8ccf0 backport #1782 to 3.x (#1785) 2019-10-28 10:42:13 -04:00
Hage Yaapa 516499dbeb chore: reduce identifier length
Existing identifier length exceeds Oracle DB's limit.
2019-09-04 21:48:34 +05:30
Hage Yaapa 020d3179aa feat: add applyDefaultOnWrites property
Adds the ability to ignore writing default values to the database.
2019-08-19 14:10:20 +05:30
Nora f6117c2c47 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-13 10:45:48 -04:00
Bill Matson 16936e0146 Fix for #1724 - Added options to attribute updates (#1725) (#1748)
* Fix for #1724 - Added options to attribute updates

* Fix for #1724 - Added unit tests for options
2019-05-31 15:06:57 -04:00
Miroslav Bajtoš 7f35e0ff2c
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:19:48 +02:00
Miroslav Bajtoš f4cbcc5f97
Fix DateString ctor to accept DateString instances
Signed-off-by: Miroslav Bajtoš <mbajtoss@gmail.com>
2019-05-13 16:08:20 +02:00
biniam 4924241028 fix: allow coercion of nested properties
Handle model definitions with nested property
definitions for coercion of primitive values.
2019-05-03 18:38:44 -04:00
biniam df4366eb31 fix: coerce primitive properties on update
Make sure we use the coerced data values for
model instance for update operation.
2019-04-18 10:12:10 -04:00
biniam f2113d2c70 fix: coerce date array properties
Make sure we coerce Date values properly when creating new
model instances.
2019-04-18 10:09:50 -04:00
Janny f21e770016
fix: add index for couchdb tests (#1720) 2019-04-17 15:16:06 -04:00
spurreiter d67aeb18b0
fix: normalize include with boolean or number
- On include = true or include = 1 the lib crashes with
  "TypeError: includes.forEach is not a function".
- checking for boolean and number type and return empty array.
- fix: include symbol and function in normalization
- fix: review changes; adding debug stmt + early exit for tests
2019-04-12 17:05:41 +02:00
Miroslav Bajtoš fd03302f08
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 introducing a new model-level setting called
`applyDefaultsOnReads`, which is enabled by default for backwards
compatibility.

When this setting is set to `false`, operations like `find` and
`findOrCreate` will NOT apply default property values on data returned
by the database (connector).

Please note that most of the other CRUD methods did not apply default
values on database data as long as the connector provided native
implementation of the operation, that aspect is not changing.

Also note that default values are applied only on properties with
`undefined` values. The value `null` does not trigger application of
default values. This is important because SQL connectors return
`null` for properties with no value set.
2019-04-09 13:03:37 +02:00
Hage Yaapa 2f093ce254
Merge pull request #1701 from strongloop/3x/list-format
feat: support array within array in 3.x
2019-03-19 19:06:14 +05:30
Hage Yaapa d8e1c2c020 feat: support array within array in 3.x 2019-03-14 16:46:03 +05:30
Hage Yaapa 05b0d16c4a feat: Support "type" key in sub-properties in 3.x 2019-03-07 16:50:29 +05:30
biniam fdcae1f583 fix: use existing field in exclude test
Co-authored-by: Raymond Feng <rfeng@us.ibm.com>
2019-01-17 15:06:45 -05:00
Miroslav Bajtoš b03ee61d37
eslint: manually fix remaining problems 2018-12-07 17:14:57 +01:00
Miroslav Bajtoš 481ad566d2
eslint: autofix linting errors 2018-12-07 17:13:48 +01:00
Raymond Feng 4a6ea992fb Use options from request for settings 2018-11-15 08:23:23 -08:00
Raymond Feng 4d66702a37 Allow flags to be passed via options 2018-11-12 11:37:45 -08:00
Raymond Feng 41d5f20fff Allow configuration of maxDepthOfQuery
https://github.com/strongloop/loopback-datasource-juggler/issues/1651
2018-10-31 09:12:43 -07:00
Raymond Feng 828fa3bcb6 Check composite keys containing hidden props 2018-10-29 13:11:50 -07:00
Raymond Feng aeee32294f Improve hidden/protected property checks
- Fixes #1645
  - do not apply hidden property check for data
- Fixes #1648
  - allow prohibitHiddenPropertiesInQuery to be set in model/ds
2018-10-29 13:11:39 -07:00
Raymond Feng 2fa5affd12 Allow hidden/protected props as an object
Fixes #1646
2018-10-27 07:55:17 -07:00
Raymond Feng 63f0fe20ed Ren handleUndefined to normalizeUndefinedInQuery 2018-10-26 09:23:10 -07:00
Raymond Feng 89bb3079bd Report circular or deep query objects 2018-10-26 09:23:01 -07:00
Raymond Feng 71f2e54de5 Hide offending properties from the error object 2018-10-26 09:19:36 -07:00
Raymond Feng bae60d1c08 Tidy up extended operator check 2018-10-26 09:18:44 -07:00
Raymond Feng 71f1259e72 Prevent hidden/protected props from being searched
- report errors if where contains hidden properties
- report errors if incldue scope contains hidden or protected properties
2018-10-26 09:18:25 -07:00
Raymond Feng 97f631bd9c Report errors for missing id props for include
https://github.com/strongloop/loopback/issues/4028
2018-10-26 09:15:50 -07:00
Dimitris 63c68bba44
remove null in embedded doc properties updates
calling patchAttributes without all embedded properties inits to null
2018-10-09 14:56:41 +02:00
Raymond Feng 7c7bd56b2e Add IBM copyright and MIT license headers 2018-09-17 09:00:12 -07:00
Raymond Feng 7eec7e4e34 Allow List to take items as instances of a class 2018-09-17 08:22:21 -07: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
Miroslav Bajtoš 38d5b5b4fa
Configure Mocha to use dot reporter
With 1965 tests, printing names of all tests is no longer useful.

This commit switches to "dot" reporter which prints a single dot per
test.
2018-07-10 12:11:46 +02:00
shenghu bc16692d9b assertation of undefined could be null 2018-07-09 11:53:27 -04:00
virkt25 9bd7f8d02f
fix: regression on Operation Hooks
Fix the regression introduced by 9af79cf51a where updateAttributes
and replaceAttributes was incorrectly handling the response returned
by the database.

This commit restores the old behaviour where `context.data` is updated
only by a connector-provided function and reverts an incorrect change
of a test file made as part of the faulty fix.

Besides the fixes, this patch also renames `data` to `dbResponse` and
add comments explaining the structure of the response object for more
clarity.
2018-07-09 16:41:56 +02:00
Miroslav Bajtoš 9af79cf51a
Fix Operation Hooks to propagate data changes
Before this change, many Operation Hooks were not correctly propagating
changes made to `ctx.data` via reassigning ctx.data to a new object.

This change modifies existing tests to account for this different
scenario, adds few more tests for scenarios that were not covered by
tests before and finally fixes the problem discovered.
2018-06-28 12:22:16 +02:00
Miroslav Bajtoš d2ee73b9d3
Update eslint + config to latest 2018-06-12 09:13:32 +02:00
Raymond Feng 2b4b44292a Fix tests to ensure compatibility w/ should@10 2018-05-24 14:21:12 -07:00
Raymond Feng 5a66f9ad72 Fix datasource state management
Use case:
1. Configure a datasource with lazyConnect = true
2. Do NOT start the DB
3. Start the app
4. Send first request and it fails to connnect to the DB
5. Start the DB
5. Requests are now served correctly
2018-05-22 10:46:45 -07:00
Raymond Feng 90163ba709 Allow toObject() to accept an 'options' argument 2018-05-10 10:18:55 -07:00
Miroslav Bajtoš 5af4c42728
feat: remove a Model from all registries
Add API allowing consumers (e.g. LoopBack) to remove a Model from all
juggler registries:
 - ModelBuilder's models
 - ModelBuilder's definitions
 - Connector registry of models
2018-04-16 14:24:53 +02:00
Janny 01427b1755 feat: omit default fn for embedsMany (#1532)
* feat: omit default fn for embeds many

* fix: apply feedback
2018-04-13 13:17:40 -04:00
bmatson c3e502032e
Pass options argument to custom validators 2018-03-22 15:51:21 +01:00