Skip to content

Commit

Permalink
Using dollar-quoted strings in comments (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
dolezel authored May 14, 2018
1 parent 3b670bf commit 2df48eb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ const formatParam = typeShorthands => param => {
export const formatParams = (params = [], typeShorthands) =>
`(${params.map(formatParam(typeShorthands)).join(", ")})`;

export const comment = (object, name, text) =>
template`COMMENT ON ${object} "${name}" IS ${text ? `'${text}'` : "NULL"};`;
export const comment = (object, name, text) => {
const cmt = escapeValue(text || null);
return template`COMMENT ON ${object} "${name}" IS ${cmt};`;
};

export const formatLines = (lines, replace = " ", separator = ",") =>
lines
Expand Down
6 changes: 6 additions & 0 deletions test/migrations/069_comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
exports.up = pgm => {
pgm.createTable("test-comment", {}, { comment: "table's comment" });
pgm.dropTable("test-comment");
};

exports.down = () => null;

0 comments on commit 2df48eb

Please sign in to comment.