Skip to content

Commit 36d997d

Browse files
committed
refactor: replace _isPrimaryKeyText by _isIntPrimaryKey
1 parent 615bf68 commit 36d997d

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

lib/sqlite3.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ SQLite3.prototype.disconnect = function disconnect(cb) {
286286
};
287287

288288
SQLite3.prototype.getInsertedId = function(model, info) {
289-
if (!this._isPrimaryKeyText(model)) {
289+
if (this._isPrimaryKeyInteger(model)) {
290290
return info.lastID;
291291
}
292292
};
@@ -368,13 +368,13 @@ SQLite3.prototype._buildColumnDefinition = function(model, propertyName) {
368368
return line;
369369
};
370370

371-
SQLite3.prototype._isPrimaryKeyText = function(model) {
371+
SQLite3.prototype._isPrimaryKeyInteger = function(model) {
372372
var properties = this.getModelDefinition(model).properties;
373373
for (var propertyName in properties) {
374374
if (!properties.hasOwnProperty(propertyName)) continue;
375375
var property = this.getModelDefinition(model).properties[propertyName];
376-
if (property.id && this._columnDataType(model, propertyName) === 'TEXT') {
377-
return true;
376+
if (property.id) {
377+
return this._columnDataType(model, propertyName) === 'INTEGER';
378378
}
379379
}
380380
return false;

test/sqlite.test.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ describe('sqlite3 connector', function() {
3333
});
3434

3535
it('should run migration', function(done) {
36-
db.automigrate('PostWithBoolean', function() {
37-
db.automigrate('ModelWithPKString', function() {
38-
done();
39-
});
36+
db.automigrate(['PostWithBoolean', 'ModelWithPKString'], function(err) {
37+
done(err);
4038
});
4139
});
4240

0 commit comments

Comments
 (0)