Comparing version 0.2.6 to 0.2.7
@@ -1,2 +0,2 @@ | ||
// Bookshelf.js 0.2.6 | ||
// Bookshelf.js 0.2.7 | ||
@@ -30,3 +30,3 @@ // (c) 2013 Tim Griesser | ||
// Keep in sync with `package.json`. | ||
Bookshelf.VERSION = '0.2.6'; | ||
Bookshelf.VERSION = '0.2.7'; | ||
@@ -482,3 +482,3 @@ // We're using `Backbone.Events` rather than `EventEmitter`, | ||
vals[keys[1]] = d; | ||
if (this.isNew(options)) vals[keys[0]] = d; | ||
if (this.isNew(options) && (!options || options.method !== 'update')) vals[keys[0]] = d; | ||
return vals; | ||
@@ -973,5 +973,7 @@ }, | ||
var syncing = this.syncing.resetQuery(); | ||
return this.query | ||
.where(syncing.idAttribute, syncing.id) | ||
.update(syncing.format(extendNull(syncing.attributes))); | ||
var query = this.query; | ||
if (syncing.id != null) { | ||
query.where(syncing.idAttribute, syncing.id); | ||
} | ||
return query.update(syncing.format(extendNull(syncing.attributes))); | ||
}, | ||
@@ -978,0 +980,0 @@ |
{ | ||
"name": "bookshelf", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "A lightweight Active Record ORM for PostgreSQL, MySQL, and SQLite3, influenced by Backbone.js", | ||
@@ -5,0 +5,0 @@ "main": "bookshelf.js", |
@@ -147,3 +147,2 @@ /*global describe, it */ | ||
}); | ||
@@ -318,2 +317,24 @@ | ||
it('does not constrain on the `id` during update unless defined', function(ok) { | ||
var m = new Bookshelf.Model({id: null}).query({where: {uuid: 'testing'}}); | ||
var query = m.query(); | ||
query.update = function() { | ||
equal(this.wheres.length, 1); | ||
return When.resolve({}); | ||
}; | ||
m.save(null, {method: 'update'}).then(function() { | ||
var m2 = new Bookshelf.Model({id: 1}).query({where: {uuid: 'testing'}}); | ||
var query2 = m2.query(); | ||
query2.update = function() { | ||
equal(this.wheres.length, 2); | ||
ok(); | ||
}; | ||
m2.save(null, {method: 'update'}); | ||
}); | ||
}); | ||
}); | ||
@@ -426,2 +447,14 @@ | ||
it('does not set created_at when {method: "update"} is passed', function(ok) { | ||
var m = new Bookshelf.Model(null, {hasTimestamps: true}); | ||
m.sync = function() { | ||
equal(this.get('item'), 'test'); | ||
equal(_.isDate(this.get('created_at')), false); | ||
equal(_.isDate(this.get('updated_at')), true); | ||
ok(); | ||
return stubSync; | ||
}; | ||
m.save({item: 'test'}, {method: 'update'}); | ||
}); | ||
}); | ||
@@ -428,0 +461,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
172827
4644