Skip to content

Commit 7f072ae

Browse files
committed
Revert "Merge pull request brianc#290 from ericjperry/master"
This reverts commit 7a64031, reversing changes made to cbd17ea.
1 parent 51ccfa3 commit 7f072ae

2 files changed

Lines changed: 5 additions & 60 deletions

File tree

lib/dialect/postgres.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Postgres.prototype._getParameterText = function(index, value) {
2626
}
2727
};
2828

29-
Postgres.prototype._getParameterValue = function(value, quoteChar) {
29+
Postgres.prototype._getParameterValue = function(value) {
3030
// handle primitives
3131
if (null === value) {
3232
value = 'NULL';
@@ -36,22 +36,13 @@ Postgres.prototype._getParameterValue = function(value, quoteChar) {
3636
// number is just number
3737
value = value;
3838
} else if ('string' === typeof value) {
39-
// string uses single quote by default
40-
value = this.quote(value, quoteChar || "'");
39+
// string uses single quote
40+
value = this.quote(value, "'");
4141
} else if ('object' === typeof value) {
4242
if (_.isArray(value)) {
4343
// convert each element of the array
44-
if (this._myClass === Postgres) {
45-
var self = this;
46-
value = value.map(function (item) {
47-
// In a Postgres array, strings must be double-quoted
48-
return self._getParameterValue(item, '"');
49-
});
50-
value = '\'{' + value.join(',') + '}\'';
51-
} else {
52-
value = _.map(value, this._getParameterValue, this);
53-
value = '(' + value.join(', ') + ')';
54-
}
44+
value = _.map(value, this._getParameterValue, this);
45+
value = '(' + value.join(', ') + ')';
5546
} else if (_.isFunction(value.toISOString)) {
5647
// Date object's default toString format does not get parsed well
5748
// Handle date like objects using toISOString

test/dialects/insert-tests.js

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
'use strict';
22

3-
var Table = require(__dirname + '/../../lib/table');
43
var Harness = require('./support');
54
var post = Harness.definePostTable();
65
var user = Harness.defineUserTable();
76

8-
var arrayTable = Table.define({
9-
name: 'arraytest',
10-
columns: ['id', 'numbers']
11-
});
12-
137
Harness.test({
148
query: post.insert(post.content.value('test'), post.userId.value(1)),
159
pg: {
@@ -636,43 +630,3 @@ Harness.test({
636630
},
637631
params: []
638632
});
639-
640-
Harness.test({
641-
query: arrayTable.insert(arrayTable.id.value(1), arrayTable.numbers.value([2, 3, 4])),
642-
pg: {
643-
text : 'INSERT INTO "arraytest" ("id", "numbers") VALUES ($1, $2)',
644-
string: 'INSERT INTO "arraytest" ("id", "numbers") VALUES (1, \'{2,3,4}\')'
645-
},
646-
sqlite: {
647-
text : 'INSERT INTO "arraytest" ("id", "numbers") VALUES ($1, $2)',
648-
string: 'INSERT INTO "arraytest" ("id", "numbers") VALUES (1, (2, 3, 4))'
649-
},
650-
mysql: {
651-
text : 'INSERT INTO `arraytest` (`id`, `numbers`) VALUES (?, ?)',
652-
string: 'INSERT INTO `arraytest` (`id`, `numbers`) VALUES (1, (2, 3, 4))'
653-
},
654-
oracle: {
655-
text : 'INSERT INTO "arraytest" ("id", "numbers") VALUES (:1, :2)',
656-
string: 'INSERT INTO "arraytest" ("id", "numbers") VALUES (1, (2, 3, 4))'
657-
}
658-
});
659-
660-
Harness.test({
661-
query: arrayTable.insert(arrayTable.id.value(1), arrayTable.numbers.value(["one", "two", "three"])),
662-
pg: {
663-
text : 'INSERT INTO "arraytest" ("id", "numbers") VALUES ($1, $2)',
664-
string: 'INSERT INTO "arraytest" ("id", "numbers") VALUES (1, \'{"one","two","three"}\')'
665-
},
666-
sqlite: {
667-
text : 'INSERT INTO "arraytest" ("id", "numbers") VALUES ($1, $2)',
668-
string: 'INSERT INTO "arraytest" ("id", "numbers") VALUES (1, (\'one\', \'two\', \'three\'))'
669-
},
670-
mysql: {
671-
text : 'INSERT INTO `arraytest` (`id`, `numbers`) VALUES (?, ?)',
672-
string: 'INSERT INTO `arraytest` (`id`, `numbers`) VALUES (1, (\'one\', \'two\', \'three\'))'
673-
},
674-
oracle: {
675-
text : 'INSERT INTO "arraytest" ("id", "numbers") VALUES (:1, :2)',
676-
string: 'INSERT INTO "arraytest" ("id", "numbers") VALUES (1, (\'one\', \'two\', \'three\'))'
677-
}
678-
});

0 commit comments

Comments
 (0)