Skip to content

Commit

Permalink
fix(createMigrationsTable): Fix bug where already-quoted search path …
Browse files Browse the repository at this point in the history
…components could get double-quoted when creating the mirations table.

Postgres's `SHOW search_path` returns the search path as a comma-separated string with spaces, like `"$user", public, "another-quoted-schema"`, so checking whether the _first character_ of a search path component is `"` is not sufficient. Instead, just check whether the search path component contains quotes at all, and don't add any quotes if it does.

Signed-off-by: Girffin Schneider <griffinschneider@gmail.com>
  • Loading branch information
GriffinSchneider committed Dec 25, 2019
1 parent 42e289b commit 79436f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -219,7 +219,7 @@ var PgDriver = Base.extend({
var searchPathes = result[0].search_path.split(',');

for (var i = 0; i < searchPathes.length; ++i) {
if (searchPathes[i].indexOf('"') !== 0) {
if (searchPathes[i].indexOf('"') !== -1) {
searchPathes[i] = '"' + searchPathes[i].trim() + '"';
}
}
Expand Down

0 comments on commit 79436f3

Please sign in to comment.