Skip to content

Commit

Permalink
Merge b0e3de1 into 08e8725
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed May 3, 2019
2 parents 08e8725 + b0e3de1 commit d0b6d96
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions test/manipulation.test.js
Expand Up @@ -985,25 +985,25 @@ describe('manipulation', function() {
it('preserves empty values from the database', async () => {
// https://github.com/strongloop/loopback-datasource-juggler/issues/1692

// Initially, all Products were always active, no property was needed
const Product = db.define('Product', {name: String});
// Initially, all Players were always active, no property was needed
const Player = db.define('Player', {name: String});

await db.automigrate('Product');
const created = await Product.create({name: 'Pen'});
await db.automigrate('Player');
const created = await Player.create({name: 'Pen'});

// Later on, we decide to introduce `active` property
Product.defineProperty('active', {
Player.defineProperty('active', {
type: Boolean,
default: false,
});
await db.autoupdate('Player');

// And updateOrCreate an existing record
const found = await Product.updateOrCreate({id: created.id, name: 'updated'});
found.toObject().should.eql({
id: created.id,
name: 'updated',
active: undefined,
});
const found = await Player.updateOrCreate({id: created.id, name: 'updated'});
should(found.toObject().active).be.oneOf([
undefined, // databases supporting `undefined` value
null, // databases representing `undefined` as `null`
]);
});
});

Expand Down Expand Up @@ -1647,25 +1647,25 @@ describe('manipulation', function() {
it('preserves empty values from the database', async () => {
// https://github.com/strongloop/loopback-datasource-juggler/issues/1692

// Initially, all Products were always active, no property was needed
const Product = db.define('Product', {name: String});
// Initially, all Players were always active, no property was needed
const Player = db.define('Player', {name: String});

await db.automigrate('Product');
const created = await Product.create({name: 'Pen'});
await db.automigrate('Player');
const created = await Player.create({name: 'Pen'});

// Later on, we decide to introduce `active` property
Product.defineProperty('active', {
Player.defineProperty('active', {
type: Boolean,
default: false,
});
await db.autoupdate('Player');

// And findOrCreate an existing record
const [found] = await Product.findOrCreate({id: created.id}, {name: 'updated'});
found.toObject().should.eql({
id: created.id,
name: 'Pen',
active: undefined,
});
const [found] = await Player.findOrCreate({id: created.id}, {name: 'updated'});
should(found.toObject().active).be.oneOf([
undefined, // databases supporting `undefined` value
null, // databases representing `undefined` as `null`
]);
});
});

Expand Down

0 comments on commit d0b6d96

Please sign in to comment.