Skip to content

Commit

Permalink
Merge 7d69bda into 84eee5a
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed Apr 9, 2019
2 parents 84eee5a + 7d69bda commit e54a28f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
22 changes: 11 additions & 11 deletions test/basic-querying.test.js
Expand Up @@ -926,25 +926,25 @@ describe('basic-querying', 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 query existing data
const found = await Product.findOne();
found.toObject().should.eql({
id: created.id,
name: 'Pen',
active: undefined,
});
const found = await Player.findOne();
should(found.toObject().active).be.oneOf([
undefined, // databases supporting `undefined` value
null, // databases representing `undefined` as `null` (e.g. SQL)
]);
});
});

Expand Down
22 changes: 11 additions & 11 deletions test/manipulation.test.js
Expand Up @@ -2615,25 +2615,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 upsertWithWhere an existing record
const found = await Product.upsertWithWhere({id: created.id}, {name: 'updated'});
found.toObject().should.eql({
id: created.id,
name: 'updated',
active: undefined,
});
const found = await Player.upsertWithWhere({id: created.id}, {name: 'updated'});
should(found.toObject().active).be.oneOf([
undefined, // databases supporting `undefined` value
null, // databases representing `undefined` as `null` (e.g. SQL)
]);
});
});
});
Expand Down

0 comments on commit e54a28f

Please sign in to comment.