Commit Graph

204 Commits

Author SHA1 Message Date
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
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
Taranveer Virk cc60ef8202 fix unauthorized fk change (#1538)
Downstream failures are unrelated.
2018-01-17 13:34:37 -05:00
Joost de Bruijn 7a4c6ca2f9 Fix query for related models (#1522) 2017-11-14 14:22:48 -05:00
zbarbuto 1d8603c491 Allow customizing embedded relation property (#1513) 2017-10-31 10:55:54 -04:00
loay e983f0c9e1 Add test coverage for hasAndBelongsToMany 2017-08-24 11:01:54 -04:00
ssh24 aec1179a30 Sort arrays before testing
Sorting the array so the ordering is the same
2017-08-02 10:45:36 -04:00
dmellonch 1b7c346bca Missing the option argument (#1426)
* Fix missing option arguments in scope.js

Added option arguments in find.relatedmodel
Added case test

* Add order filter in verify function

Fix for cloudant test
2017-08-01 14:15:21 -04:00
Jürg Lehni 4c9e91423f
Rename getAsync() methods to find() and get()
Keep getAsync() around for backward compatibility, but deprecate it
2017-07-20 14:48:29 +02:00
Janny b9129e6973 Run juggler tests for Cloudant (#1414) 2017-07-11 14:56:39 -04:00
Tetsuo Seto 4a6f0a4aa0 Fix the case where qWhere[idKey] is null 2017-06-09 09:33:22 -07:00
Tetsuo Seto ef08458e8d Remove unnecessary tests for adhocSort !== false 2017-05-15 03:04:09 -07:00
Tetsuo Seto c07f46000d Support include rework for C* connector
- Remove supportNonPrimaryKeyIN
- Add C* Uuid in build call
- Implement smartMerge in scope.js
2017-05-12 22:43:21 -07:00
ebarault cfd3cdf535 Overall review of polymorphic relations
In #1298, the spec/doc for polymorphic relations was reviewed

**hasX relation**
- `type`: **hasMany**
- `as`: redefines **this** relation's name (optional)
- `model`: **modelTo**
- `polymorphic`:
  - typeOf `polymorphic` === `String`
    - matching **belongsTo** relation name
      - `foreignKey` is generated as `polymorphic + 'Id'`,
      - `discriminator` is generated as `polymorphic + 'Type'`
  - typeOf `polymorphic` === `Object`
    - `as`: **DEPRECATED** should display a warning,
            replaced by `selector`
    - `selector`: should match **belongsTo** relation name if the
                  latter is defined with {polymorphic: true}
      - (required) if both foreignKey and discriminator
        are **NOT** provided
      - (extraneous) if both foreignKey and discriminator
        are provided
    - `foreignKey`:  A property of modelTo, representing the fk to
       modelFrom's id.
      - generated by default as `selector + 'Id'`
    - `discriminator`: A property of modelTo, representing the actual
                       modelFrom to be looked up and defined
                       dynamically
      - generated by default as `selector + 'Type'`

---

**belongsTo relation**
- `type`: **belongsTo**
- `as`: redefines **this** relation's name (optional)
- `model`: **NOT EXPECTED**: should throw an error at
               relation validation
- `polymorphic`:
  - typeOf `polymorphic` === `Boolean`
      - `foreignKey` is generated as `relationName + 'Id'`,
      - `discriminator` is generated as `relationName + 'Type'`
  - typeOf `polymorphic` === `Object`
    - `as`: **DEPRECATED**: should display a warning,
            replaced by `selector`
    - `selector`:
      - (required) if both foreignKey and discriminator
        are **NOT** provided
      - (extraneous) if both foreignKey and discriminator
        are provided
    - `foreignKey`: A property of modelTo, representing the fk to
                    modelFrom's id.
      - generated by default as `selector + 'Id'`
    - `discriminator`: A property of modelTo, representing the actual
                       modelFrom to be looked up and defined
                       dynamically
      - generated by default as `selector + 'Type'`
2017-05-12 21:33:39 +02:00
Janny 5d10c72664 create sequence for nosql id (#1354)
* create sequence for nosql id
2017-05-02 13:35:57 -04:00
loay 1cdb431ae2 Fix relations test case 2017-04-14 03:35:46 -04:00
Tetsuo Seto c1598584d8 Make tests work for other connectors as well as C*
Adjust getSchema calls
Compare ids as strings
Run tests when explicitly set to true
2017-04-12 09:11:42 -07:00
Tetsuo Seto 696e4cfa80 Remove debugger statement 2017-04-07 15:05:15 -07:00
Tetsuo Seto 0f9100f185 Fixup test support for Cassandra connector 2017-04-07 14:11:33 -07:00
Tetsuo Seto ead1fb2965 Add test support for Cassandra connector 2017-04-07 11:10:47 -07:00
Waldemar Zahn ef143dc5eb Custom Table Names on rels (#1303)
hasAndBelongsToMany relation
2017-04-05 12:42:21 -04:00
Clark Wang c99441247c Fix - `_targetClass` on scope function (#1280)
Fix `_targetClass` on scope function when using hasManyThrough
relation with customized relation names and foreignKey/keyThrough.

This bug is cause by `_targetClass` uses the camel-case of
`relationName`(e.g.: if `relationName` is `bbb`, `targetClass`
would be `Bbb`), which is not exists.

This will also suppress "not exposed" warnings when generating
angular sdk, and generate end-points for this scope.
2017-03-22 17:06:36 -04:00
Nick Oikonomou b3a7bc521d Fixes #1275. `Include` filter transforms fields property into array. (#1276)
* Fixes#1275 Transform *fields* property into array

`Include` filter takes into consideration string property
'fields' and transforms it into an array containing this string.

* Added error handling for `include` filter.

* ExecTasksWithInterLeave now contains a try-catch block
 in order to catch any unexpected errors.

* LinkManyToMany now checks if *modelToIdName* exists on
 *target* before continuing.

* Added unit test for *include* with string fields
2017-03-22 10:03:36 -04:00
Miroslav Bajtoš d809260799 Upgrade eslint-config, fix new violations 2017-02-01 12:45:56 +01: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
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
jannyHou 6c8e806bc8 Apply hasManyThrough filter on target model 2016-12-01 10:08:27 -05:00
Loay 2cb0d042e4 Fix CI Failures in MySQL 2016-09-26 20:27:33 -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
Miroslav Bajtoš baec1b5b77 test/relation: add missing error handlers 2016-08-08 16:26:26 -04:00
jannyHou 8935b978f3 forceId=true with auto-increment db 2016-08-08 16:26:26 -04:00
Dimitris Halatsis ea2266e453 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();
      })

[forward-port of #949]
2016-06-07 17:24:59 +02:00
Dimitris Halatsis b7ba73f1b1 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',
      },
    });
2016-06-01 13:12:50 +02:00
Alex Pitigoi 0e89a9c837 fix avoid duplicate record on scope with promise 2016-05-19 15:47:31 -04:00
Miroslav Bajtoš c7f34c3452 eslint config 2.0 + remove extra empty lines
Upgrade eslint-config-loopback to ^2.0.0.

Remove extra empty lines to make `npm run lint` pass again.
2016-04-19 16:11:43 +02:00
Miroslav Bajtoš 27c6279d6c fix remaining eslint issues 2016-04-05 15:25:34 +02:00
Miroslav Bajtoš 39e04a1756 eslint --fix 2016-04-05 15:25:34 +02:00
Ryan Graham c467b43c38 Insert copyright headers 2016-04-04 18:14:03 -07:00
Raymond Feng d7bbd7e215 Fix the typo 2015-11-17 13:27:41 -08:00
mdartic ef7fe45d9c Rewrite of variable 2015-10-16 18:25:23 +02:00
mdartic 7c22db6ea7 Filtering relations of a model with an order specified 2015-10-16 18:21:04 +02:00
Raymond Feng 1e035c657e Fix the test so that it works across DBs 2015-09-11 11:15:00 -07:00
Raymond Feng a6519bb2ca Fix id comparision in tests so that they work with mongodb object id 2015-09-08 09:53:02 -07:00
sklyukin d0f9b760f5 primaryKey for hasMany and belongsTo relations 2015-09-01 19:03:02 +05:00
sklyukin 483cd873e7 primaryKey to hasOne relation 2015-09-01 01:31:28 +05:00
Raymond Feng 682f6340d3 Optimze automigrate() to cut the test time signicantly 2015-08-27 15:59:58 -07:00