Repository: genjidb/genji
Pull request #439 (2022-01-25 07:19:34)

fixe restore command
This is a fix for #430.

codecov[bot]: # [Codecov](https://codecov.io/gh/genjidb/genji/pull/439?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb) Report
> Merging [#439](https://codecov.io/gh/genjidb/genji/pull/439?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb) (0a9b43d) into [main](https://codecov.io/gh/genjidb/genji/commit/2f8ba9907eec495c4e837aa70dcb9b3d8b97c4b7?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb) (2f8ba99) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/genjidb/genji/pull/439/graphs/tree.svg?width=650&height=150&src=pr&token=nwR1GpvtyH&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb)](https://codecov.io/gh/genjidb/genji/pull/439?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb)

```diff
@@           Coverage Diff           @@
##             main     #439   +/-   ##
=======================================
  Coverage   79.50%   79.51%           
=======================================
  Files          95       95           
  Lines        9658     9662    +4     
=======================================
+ Hits         7679     7683    +4     
  Misses       1327     1327           
  Partials      652      652           
```


| [Impacted Files](https://codecov.io/gh/genjidb/genji/pull/439?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb) | Coverage Δ | |
|---|---|---|
| [internal/sql/scanner/scanner.go](https://codecov.io/gh/genjidb/genji/pull/439/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb#diff-aW50ZXJuYWwvc3FsL3NjYW5uZXIvc2Nhbm5lci5nbw==) | `86.42% <100.00%> (+0.14%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/genjidb/genji/pull/439?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/genjidb/genji/pull/439?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb). Last update [2f8ba99...0a9b43d](https://codecov.io/gh/genjidb/genji/pull/439?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb).


Patch:
diff --git a/internal/sql/scanner/scanner.go b/internal/sql/scanner/scanner.go
index a970cf45..b15d0d4f 100644
--- a/internal/sql/scanner/scanner.go
+++ b/internal/sql/scanner/scanner.go
@@ -604,6 +604,10 @@ func scanString(r io.RuneReader) (string, error) {
 			ch1, _, _ := r.ReadRune()
 			if ch1 == 'n' {
 				_, _ = buf.WriteRune('\n')
+			} else if ch1 == 'r' {
+				_, _ = buf.WriteRune('\r')
+			} else if ch1 == 't' {
+				_, _ = buf.WriteRune('\t')
 			} else if ch1 == '\\' {
 				_, _ = buf.WriteRune('\\')
 			} else if ch1 == '"' {


Test patch:
diff --git a/internal/sql/scanner/scanner_test.go b/internal/sql/scanner/scanner_test.go
index f28005fd..e22c05ee 100644
--- a/internal/sql/scanner/scanner_test.go
+++ b/internal/sql/scanner/scanner_test.go
@@ -268,6 +268,10 @@ func TestScanString(t *testing.T) {
 		{in: `"foo bar"`, out: `foo bar`},
 		{in: `'foo bar'`, out: `foo bar`},
 		{in: `"foo\nbar"`, out: "foo\nbar"},
+		{in: `"foo\rbar"`, out: "foo\rbar"},
+		{in: `"foo\tbar"`, out: "foo\tbar"},
+		{in: `"foo\r\nbar"`, out: "foo\r\nbar"},
+		{in: `"foo\r\nbar\r\n\trm"`, out: "foo\r\nbar\r\n\trm"},
 		{in: `"foo\\bar"`, out: `foo\bar`},
 		{in: `"foo\"bar"`, out: `foo"bar`},
 		{in: `'foo\'bar'`, out: `foo'bar`},