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

Commit bbd796f4 by sdepold

use INTEGER instead of INT

1 parent cf02ceb1
...@@ -17,18 +17,18 @@ describe('BelongsTo', function() { ...@@ -17,18 +17,18 @@ describe('BelongsTo', function() {
it('adds the foreign key', function() { it('adds the foreign key', function() {
Task.belongsTo(User) Task.belongsTo(User)
expect(Task.attributes['UserId']).toEqual("INT") expect(Task.attributes['UserId']).toEqual("INTEGER")
}) })
it("underscores the foreign key", function() { it("underscores the foreign key", function() {
Task = sequelize.define('Task', { title: Sequelize.STRING }, {underscored: true}) Task = sequelize.define('Task', { title: Sequelize.STRING }, {underscored: true})
Task.belongsTo(User) Task.belongsTo(User)
expect(Task.attributes['user_id']).toEqual("INT") expect(Task.attributes['user_id']).toEqual("INTEGER")
}) })
it("uses the passed foreign key", function() { it("uses the passed foreign key", function() {
Task.belongsTo(User, {foreignKey: 'person_id'}) Task.belongsTo(User, {foreignKey: 'person_id'})
expect(Task.attributes['person_id']).toEqual("INT") expect(Task.attributes['person_id']).toEqual("INTEGER")
}) })
it("defines getters and setters", function() { it("defines getters and setters", function() {
......
...@@ -25,7 +25,7 @@ describe('HasMany', function() { ...@@ -25,7 +25,7 @@ describe('HasMany', function() {
describe('mono-directional', function() { describe('mono-directional', function() {
it("adds the foreign key", function() { it("adds the foreign key", function() {
User.hasMany(Task) User.hasMany(Task)
expect(Task.attributes.UserId).toEqual("INT") expect(Task.attributes.UserId).toEqual("INTEGER")
}) })
it('adds the foreign key with underscore', function() { it('adds the foreign key with underscore', function() {
...@@ -39,7 +39,7 @@ describe('HasMany', function() { ...@@ -39,7 +39,7 @@ describe('HasMany', function() {
it('uses the passed foreign key', function() { it('uses the passed foreign key', function() {
User.hasMany(Task, { foreignKey: 'person_id' }) User.hasMany(Task, { foreignKey: 'person_id' })
expect(Task.attributes.person_id).toEqual("INT") expect(Task.attributes.person_id).toEqual("INTEGER")
}) })
it('defines getters and setters', function() { it('defines getters and setters', function() {
......
...@@ -17,7 +17,7 @@ describe('HasOne', function() { ...@@ -17,7 +17,7 @@ describe('HasOne', function() {
it("adds the foreign key", function() { it("adds the foreign key", function() {
User.hasOne(Task) User.hasOne(Task)
expect(Task.attributes.UserId).toEqual("INT") expect(Task.attributes.UserId).toEqual("INTEGER")
}) })
it("adds an underscored foreign key", function() { it("adds an underscored foreign key", function() {
...@@ -25,7 +25,7 @@ describe('HasOne', function() { ...@@ -25,7 +25,7 @@ describe('HasOne', function() {
Task = sequelize.define('Task', { title: Sequelize.STRING }) Task = sequelize.define('Task', { title: Sequelize.STRING })
User.hasOne(Task) User.hasOne(Task)
expect(Task.attributes.user_id).toEqual("INT") expect(Task.attributes.user_id).toEqual("INTEGER")
}) })
it("uses the passed foreign key", function() { it("uses the passed foreign key", function() {
...@@ -33,7 +33,7 @@ describe('HasOne', function() { ...@@ -33,7 +33,7 @@ describe('HasOne', function() {
Task = sequelize.define('Task', { title: Sequelize.STRING }) Task = sequelize.define('Task', { title: Sequelize.STRING })
User.hasOne(Task, {foreignKey: 'person_id'}) User.hasOne(Task, {foreignKey: 'person_id'})
expect(Task.attributes.person_id).toEqual("INT") expect(Task.attributes.person_id).toEqual("INTEGER")
}) })
it("defines the getter and the setter", function() { it("defines the getter and the setter", function() {
......
...@@ -14,21 +14,21 @@ describe('ModelFactory', function() { ...@@ -14,21 +14,21 @@ describe('ModelFactory', function() {
var User = sequelize.define('User' + config.rand(), { var User = sequelize.define('User' + config.rand(), {
username: { type: Sequelize.STRING, unique: true } username: { type: Sequelize.STRING, unique: true }
}, { timestamps: false }) }, { timestamps: false })
expect(User.attributes).toEqual({username:"VARCHAR(255) UNIQUE",id:"INT NOT NULL auto_increment PRIMARY KEY"}) expect(User.attributes).toEqual({username:"VARCHAR(255) UNIQUE",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"})
}) })
it("handles extended attributes (default)", function() { it("handles extended attributes (default)", function() {
var User = sequelize.define('User' + config.rand(), { var User = sequelize.define('User' + config.rand(), {
username: {type: Sequelize.STRING, defaultValue: 'foo'} username: {type: Sequelize.STRING, defaultValue: 'foo'}
}, { timestamps: false }) }, { timestamps: false })
expect(User.attributes).toEqual({username:"VARCHAR(255) DEFAULT 'foo'",id:"INT NOT NULL auto_increment PRIMARY KEY"}) expect(User.attributes).toEqual({username:"VARCHAR(255) DEFAULT 'foo'",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"})
}) })
it("handles extended attributes (null)", function() { it("handles extended attributes (null)", function() {
var User = sequelize.define('User' + config.rand(), { var User = sequelize.define('User' + config.rand(), {
username: {type: Sequelize.STRING, allowNull: false} username: {type: Sequelize.STRING, allowNull: false}
}, { timestamps: false }) }, { timestamps: false })
expect(User.attributes).toEqual({username:"VARCHAR(255) NOT NULL",id:"INT NOT NULL auto_increment PRIMARY KEY"}) expect(User.attributes).toEqual({username:"VARCHAR(255) NOT NULL",id:"INTEGER NOT NULL auto_increment PRIMARY KEY"})
}) })
it("handles extended attributes (primaryKey)", function() { it("handles extended attributes (primaryKey)", function() {
...@@ -42,18 +42,18 @@ describe('ModelFactory', function() { ...@@ -42,18 +42,18 @@ describe('ModelFactory', function() {
var User1 = sequelize.define('User' + config.rand(), {}) var User1 = sequelize.define('User' + config.rand(), {})
var User2 = sequelize.define('User' + config.rand(), {}, { timestamps: true }) var User2 = sequelize.define('User' + config.rand(), {}, { timestamps: true })
expect(User1.attributes).toEqual({id:"INT NOT NULL auto_increment PRIMARY KEY", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"}) expect(User1.attributes).toEqual({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"})
expect(User2.attributes).toEqual({id:"INT NOT NULL auto_increment PRIMARY KEY", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"}) expect(User2.attributes).toEqual({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"})
}) })
it("adds deletedAt if paranoid", function() { it("adds deletedAt if paranoid", function() {
var User = sequelize.define('User' + config.rand(), {}, { paranoid: true }) var User = sequelize.define('User' + config.rand(), {}, { paranoid: true })
expect(User.attributes).toEqual({id:"INT NOT NULL auto_increment PRIMARY KEY", deletedAt:"DATETIME", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"}) expect(User.attributes).toEqual({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", deletedAt:"DATETIME", updatedAt:"DATETIME NOT NULL", createdAt:"DATETIME NOT NULL"})
}) })
it("underscores timestamps if underscored", function() { it("underscores timestamps if underscored", function() {
var User = sequelize.define('User' + config.rand(), {}, { paranoid: true, underscored: true }) var User = sequelize.define('User' + config.rand(), {}, { paranoid: true, underscored: true })
expect(User.attributes).toEqual({id:"INT NOT NULL auto_increment PRIMARY KEY", deleted_at:"DATETIME", updated_at:"DATETIME NOT NULL", created_at:"DATETIME NOT NULL"}) expect(User.attributes).toEqual({id:"INTEGER NOT NULL auto_increment PRIMARY KEY", deleted_at:"DATETIME", updated_at:"DATETIME NOT NULL", created_at:"DATETIME NOT NULL"})
}) })
}) })
......
...@@ -47,7 +47,7 @@ describe('Utils', function() { ...@@ -47,7 +47,7 @@ describe('Utils', function() {
}) })
it('detects primary keys if length is correct and data types are matching', function() { it('detects primary keys if length is correct and data types are matching', function() {
expect(Utils.argsArePrimaryKeys([1,2,3], ["INT", "INT", "INT"])).toBeTruthy() expect(Utils.argsArePrimaryKeys([1,2,3], ["INTEGER", "INTEGER", "INTEGER"])).toBeTruthy()
}) })
it("detects primary keys if primary keys are dates and lengths are matching", function() { it("detects primary keys if primary keys are dates and lengths are matching", function() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!