Comparing version 0.6.8 to 0.6.9
@@ -1,2 +0,2 @@ | ||
// Bookshelf.js 0.6.8 | ||
// Bookshelf.js 0.6.9 | ||
// --------------- | ||
@@ -74,3 +74,3 @@ | ||
// centralizing all logic dealing with type & option handling. | ||
var Relation = Bookshelf.Relation = SqlRelation.extend({ | ||
var Relation = this.Relation = SqlRelation.extend({ | ||
Model: ModelCtor, | ||
@@ -91,3 +91,3 @@ Collection: CollectionCtor | ||
// Keep in sync with `package.json`. | ||
VERSION: '0.6.8', | ||
VERSION: '0.6.9', | ||
@@ -94,0 +94,0 @@ // Helper method to wrap a series of Bookshelf actions in a `knex` transaction block; |
@@ -24,3 +24,3 @@ // Sync | ||
// current table name | ||
prefixFields: function (fields) { | ||
prefixFields: function(fields) { | ||
var tableName = this.syncing.tableName; | ||
@@ -37,5 +37,5 @@ var prefixed = {}; | ||
first: Promise.method(function() { | ||
this.query.where(this.syncing.format( | ||
_.extend(Object.create(null), this.prefixFields(this.syncing.attributes))) | ||
).limit(1); | ||
this.query.where(this.prefixFields(this.syncing.format( | ||
_.extend(Object.create(null), this.syncing.attributes) | ||
))).limit(1); | ||
return this.select(); | ||
@@ -42,0 +42,0 @@ }), |
{ | ||
"name": "bookshelf", | ||
"version": "0.6.8", | ||
"version": "0.6.9", | ||
"description": "A lightweight ORM for PostgreSQL, MySQL, and SQLite3, influenced by Backbone.js", | ||
@@ -5,0 +5,0 @@ "main": "bookshelf.js", |
@@ -159,9 +159,4 @@ var Promise = global.testPromise; | ||
}).then(function(photo) { | ||
console.log('here'); | ||
expect(photo.get('url')).to.equal('http://image.dev'); | ||
return photo.destroy(); | ||
}); | ||
@@ -168,0 +163,0 @@ |
@@ -253,3 +253,3 @@ var _ = require('lodash'); | ||
var count = 0; | ||
var model = new Site({id: 1}); | ||
var model = Site.forge({id: 1}); | ||
model.on('fetched', function() { | ||
@@ -256,0 +256,0 @@ count++; |
@@ -14,15 +14,30 @@ var Promise = testPromise; | ||
describe('Sync', function() { | ||
var noop = function() {}; | ||
var stubSyncing = { | ||
query: noop, | ||
resetQuery: function () { | ||
return { | ||
tableName: 'testtable' | ||
}; | ||
} | ||
var stubSync = function() { | ||
var qd = []; | ||
var stubQuery = function() { | ||
qd.push(_.toArray(arguments)); | ||
return this; | ||
}; | ||
return { | ||
tableName: 'testtable', | ||
queryData: qd, | ||
query: function() { | ||
return { | ||
where: stubQuery, | ||
limit: stubQuery | ||
}; | ||
}, | ||
resetQuery: function () { | ||
return this; | ||
} | ||
}; | ||
}; | ||
describe('prefixFields', function () { | ||
var sync = new Sync(stubSyncing); | ||
it('should prefix all keys of the passed in object with the tablename', function () { | ||
var sync = new Sync(stubSync()); | ||
var attributes = { | ||
@@ -33,3 +48,3 @@ 'some': 'column', | ||
var isPrefixed = _.isEqual(sync.prefixFields(attributes), { | ||
expect(sync.prefixFields(attributes)).to.eql({ | ||
'testtable.some':'column', | ||
@@ -39,4 +54,27 @@ 'testtable.another':'column' | ||
expect(isPrefixed).to.be.true; | ||
}); | ||
it('should run after format', function() { | ||
var sync = new Sync(_.extend(stubSync(), { | ||
format: function(attrs) { | ||
var data = {}; | ||
for (var key in attrs) { | ||
data[key.toLowerCase()] = attrs[key]; | ||
} | ||
return data; | ||
}, | ||
attributes: { | ||
'Some': 'column', | ||
'Another': 'column' | ||
} | ||
})); | ||
sync.select = function() { | ||
expect(this.syncing.queryData[0]).to.eql([{ | ||
"testtable.some": "column", | ||
"testtable.another": "column" | ||
}]); | ||
}; | ||
return sync.first(); | ||
}); | ||
@@ -46,2 +84,3 @@ | ||
}); | ||
@@ -48,0 +87,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
287608
7890