不要怂,就是干,撸起袖子干!

Commit 45a56dcb by whito

find a string based primaryKey called id

1 parent d633069a
Showing with 25 additions and 1 deletions
...@@ -101,7 +101,7 @@ module.exports = (function() { ...@@ -101,7 +101,7 @@ module.exports = (function() {
this.primaryKeys = {}; this.primaryKeys = {};
Utils._.each(this.attributes, function(dataTypeString, attributeName) { Utils._.each(this.attributes, function(dataTypeString, attributeName) {
if ((attributeName !== 'id') && (dataTypeString.indexOf('PRIMARY KEY') !== -1)) { if (dataTypeString.indexOf('PRIMARY KEY') !== -1) {
self.primaryKeys[attributeName] = dataTypeString self.primaryKeys[attributeName] = dataTypeString
} }
}) })
......
...@@ -1490,6 +1490,30 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () { ...@@ -1490,6 +1490,30 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
}) })
}) })
it('finds entries via a string primary key called id', function(done) {
var self = this
, UserPrimary = self.sequelize.define('UserWithPrimaryKey', {
id: {type: Sequelize.STRING, primaryKey: true},
name: Sequelize.STRING
})
UserPrimary.sync({ force: true }).success(function() {
UserPrimary.create({
id: 'a string based id',
name: 'John'
}).success(function(u) {
expect(u.id).not.to.exist
UserPrimary.find('a string based id').success(function(u2) {
expect(u2.id).to.equal('a string based id')
expect(u2.name).to.equal('John')
done()
})
})
})
})
it('returns the selected fields as instance.selectedValues', function(done) { it('returns the selected fields as instance.selectedValues', function(done) {
var self = this var self = this
this.User.create({ this.User.create({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!