Skip to content

Commit

Permalink
Make format work when run client side (dataform-co#886)
Browse files Browse the repository at this point in the history
* Make format work client side

* Swapped to uuid
  • Loading branch information
Ekrekr authored Jul 14, 2020
1 parent ae4cc15 commit 6c5d81a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sqlx/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ ts_library(
"@npm//@types/moo",
"@npm//@types/node",
"@npm//@types/js-beautify",
"@npm//@types/uuid",
"@npm//js-beautify",
"@npm//uuid",
"@npm//sql-formatter",
"@npm//moo",
],
Expand Down
5 changes: 4 additions & 1 deletion sqlx/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { promisify } from "util";

import { ErrorWithCause } from "df/common/errors/errors";
import { SyntaxTreeNode, SyntaxTreeNodeType } from "df/sqlx/lexer";
import { v4 as uuidv4 } from "uuid";

const JS_BEAUTIFY_OPTIONS: JsBeautifyOptions = {
indent_size: 2,
Expand Down Expand Up @@ -165,7 +166,9 @@ function stripUnformattableText(
}

function generatePlaceholderId() {
return crypto.randomBytes(8).toString("hex");
return uuidv4()
.replace(/-/g, "")
.substring(0, 16);
}

function replacePlaceholders(
Expand Down

0 comments on commit 6c5d81a

Please sign in to comment.