Skip to content

Commit f5d80d6

Browse files
committed
Changes after review
1 parent e118c49 commit f5d80d6

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

Diff for: lib/postgresql.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -766,12 +766,10 @@ PostgreSQL.prototype.toColumnValue = function(prop, val, isWhereClause) {
766766
});
767767
}
768768

769-
if (prop.type instanceof Array) {
769+
if (Array.isArray(prop.type)) {
770770
// There is two possible cases for the type of "val" as well as two cases for dataType
771-
const isArrayDataType = prop.postgresql &&
772-
prop.postgresql.dataType &&
773-
(prop.postgresql.dataType.indexOf('[]') > -1);
774-
if (val instanceof Array) {
771+
const isArrayDataType = prop.postgresql && prop.postgresql.dataType === 'varchar[]';
772+
if (Array.isArray(val)) {
775773
if (isArrayDataType) {
776774
return val;
777775
} else {

Diff for: test/postgresql.test.js

+15-6
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,19 @@ describe('postgresql connector', function() {
216216
.then((post)=> {
217217
postId = post.id;
218218
post.should.have.property('tags');
219-
post.tags[1].should.eql('AB');
219+
post.tags.should.be.Array();
220+
post.tags.length.should.eql(2);
221+
post.tags.should.eql(['AA', 'AB']);
220222
return Post.updateAll({where: {id: postId}}, {tags: ['AA', 'AC']});
221223
})
222-
.then((wooot)=> {
224+
.then(()=> {
223225
return Post.findOne({where: {id: postId}});
224226
})
225227
.then((post)=> {
226228
post.should.have.property('tags');
227-
post.tags[1].should.eql('AC');
229+
post.tags.should.be.Array();
230+
post.tags.length.should.eql(2);
231+
post.tags.should.eql(['AA', 'AC']);
228232
done();
229233
})
230234
.catch((error) => {
@@ -238,15 +242,20 @@ describe('postgresql connector', function() {
238242
.then((post)=> {
239243
postId = post.id;
240244
post.should.have.property('categories');
241-
post.categories[1].should.eql('AB');
245+
post.should.have.property('categories');
246+
post.categories.should.be.Array();
247+
post.categories.length.should.eql(2);
248+
post.categories.should.eql(['AA', 'AB']);
242249
return Post.updateAll({where: {id: postId}}, {categories: ['AA', 'AC']});
243250
})
244-
.then((wooot)=> {
251+
.then(()=> {
245252
return Post.findOne({where: {id: postId}});
246253
})
247254
.then((post)=> {
248255
post.should.have.property('categories');
249-
post.categories[1].should.eql('AC');
256+
post.categories.should.be.Array();
257+
post.categories.length.should.eql(2);
258+
post.categories.should.eql(['AA', 'AC']);
250259
done();
251260
})
252261
.catch((error) => {

0 commit comments

Comments
 (0)