Skip to content

Commit

Permalink
fix(addForeignKey): pass joined strings to util.format
Browse files Browse the repository at this point in the history
node v12 seems to no longer format arrays passed as strings by
`.toString()`ing them, which effectively resulted in a `.join(',')`, but
returning in something to the tune of:

```
> util.format('%s', ['foo','bar'])
"[ 'foo', 'bar' ]"
```

While v11.15.0 returns:
```
> util.format('%s', ['foo','bar'])
'foo,bar'
```

This fixes this issue on v12, and doesn't break any other version.

Signed-off-by: Maciej Małecki <me@mmalecki.com>
Reported-by: Marcin Smołka <marcinsa12@gmail.com>
  • Loading branch information
mmalecki committed May 6, 2019
1 parent 8c6435a commit 21cbfe5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,9 @@ var PgDriver = Base.extend({
'ALTER TABLE "%s" ADD CONSTRAINT "%s" FOREIGN KEY (%s) REFERENCES "%s" (%s) ON DELETE %s ON UPDATE %s',
tableName,
keyName,
this.quoteDDLArr(columns),
this.quoteDDLArr(columns).join(', '),
referencedTableName,
referencedColumns,
referencedColumns.join(', '),
rules.onDelete || 'NO ACTION',
rules.onUpdate || 'NO ACTION'
);
Expand Down

0 comments on commit 21cbfe5

Please sign in to comment.