Skip to content

Commit

Permalink
refactor: replace _isPrimaryKeyText by _isIntPrimaryKey
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoPoi committed Nov 30, 2020
1 parent 615bf68 commit 4634de9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/sqlite3.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ SQLite3.prototype.disconnect = function disconnect(cb) {
};

SQLite3.prototype.getInsertedId = function(model, info) {
if (!this._isPrimaryKeyText(model)) {
if (this._isPrimaryKeyInteger(model)) {
return info.lastID;
}
};
Expand Down Expand Up @@ -368,16 +368,16 @@ SQLite3.prototype._buildColumnDefinition = function(model, propertyName) {
return line;
};

SQLite3.prototype._isPrimaryKeyText = function(model) {
SQLite3.prototype._isPrimaryKeyInteger = function(model) {
var properties = this.getModelDefinition(model).properties;
for (var propertyName in properties) {
if (!properties.hasOwnProperty(propertyName)) continue;
var property = this.getModelDefinition(model).properties[propertyName];
if (property.id && this._columnDataType(model, propertyName) === 'TEXT') {
return true;
return false;
}
}
return false;
return true;
};

function _convertBoolean(value) {
Expand Down
6 changes: 2 additions & 4 deletions test/sqlite.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ describe('sqlite3 connector', function() {
});

it('should run migration', function(done) {
db.automigrate('PostWithBoolean', function() {
db.automigrate('ModelWithPKString', function() {
done();
});
db.automigrate(['PostWithBoolean', 'ModelWithPKString'], function(err) {
done(err);
});
});

Expand Down

0 comments on commit 4634de9

Please sign in to comment.