nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: node-influx/node-influx
Pull request #519 (2020-07-29 15:10:17)

517
Fixes #517 Lint Errors

## Proposed Changes

- #517
- Fixes lint errors

## Checklist

- [x] A test has been added if appropriate
- [ ] `npm test` completes successfully
- [ ] Commit messages are in [semantic format](https://seesparkbox.com/foundry/semantic_commit_messages)



Patch:
diff --git a/src/grammar/escape.ts b/src/grammar/escape.ts
index dbb67a0..24dc085 100644
--- a/src/grammar/escape.ts
+++ b/src/grammar/escape.ts
@@ -60,7 +60,9 @@ class Escaper {
 
     let match;
 
-    val = val.replace(/\\'/, "\\\\'");
+    if (typeof val === "string") {
+      val = val.replace(/\\'/, "\\\\'");
+    }
 
     /* eslint-disable no-cond-assign */
     while ((match = this._re.exec(val))) {


Test patch:
diff --git a/test/unit/grammar.test.ts b/test/unit/grammar.test.ts
index cde9593..c7606ce 100644
--- a/test/unit/grammar.test.ts
+++ b/test/unit/grammar.test.ts
@@ -21,11 +21,12 @@ describe("grammar", () => {
     ).to.equal('don"t escape');
   });
 
-  it("escapes backslashes (issue #486)", () => {
+  it("escapes backslashes (issues #486, #516)", () => {
     // eslint-disable-next-line quotes
     expect(grammar.escape.stringLit("GAZP()\\' or 1=1 --")).to.equal(
       "'GAZP()\\\\\\' or 1=1 --'"
     );
+    expect(grammar.escape.tag(1 as any)).to.equal("1");
   });
 
   it("escapes complex values (issue #242)", () => {