Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c79c1e2

Browse files
btdbendrucker
authored andcommitted
Discard postgres array indexes
Closes bendrucker#6
1 parent d73c5b2 commit c79c1e2

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,18 @@ ArrayParser.prototype.newEntry = function (includeEmpty) {
4848
}
4949
}
5050

51+
ArrayParser.prototype.consumeDimensions = function () {
52+
if (this.source[0] === '[') {
53+
while (!this.isEof()) {
54+
var char = this.nextCharacter()
55+
if (char.value === '=') break
56+
}
57+
}
58+
}
59+
5160
ArrayParser.prototype.parse = function (nested) {
5261
var character, parser, quote
62+
this.consumeDimensions()
5363
while (!this.isEof()) {
5464
character = this.nextCharacter()
5565
if (character.value === '{' && !quote) {

test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ test(function (t) {
1515

1616
var integer = ap.partialRight(array.parse, ap.partialRight(parseInt, 10))
1717
t.deepEqual(integer('{1,2,3}'), [1, 2, 3], 'numerics')
18+
t.deepEqual(integer('[0:2]={1,2,3}'), [1, 2, 3], 'numerics')
1819

1920
t.end()
2021
})

0 commit comments

Comments
 (0)