Repository: genjidb/genji
Pull request #440 (2022-01-25 10:38:06)

update cli insert usage
`engine` option is no longer supported. 

codecov[bot]: # [Codecov](https://codecov.io/gh/genjidb/genji/pull/440?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb) Report
> Merging [#440](https://codecov.io/gh/genjidb/genji/pull/440?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb) (a5c3faf) 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 **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/genjidb/genji/pull/440/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/440?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb)

```diff
@@           Coverage Diff           @@
##             main     #440   +/-   ##
=======================================
  Coverage   79.50%   79.50%           
=======================================
  Files          95       95           
  Lines        9658     9658           
=======================================
  Hits         7679     7679           
  Misses       1327     1327           
  Partials      652      652           
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/genjidb/genji/pull/440?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/440?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=genjidb). Last update [2f8ba99...a5c3faf](https://codecov.io/gh/genjidb/genji/pull/440?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/cmd/genji/commands/insert.go b/cmd/genji/commands/insert.go
index e342bcd0..73eb452c 100644
--- a/cmd/genji/commands/insert.go
+++ b/cmd/genji/commands/insert.go
@@ -8,8 +8,9 @@ import (
 	"time"
 
 	"github.com/cockroachdb/errors"
-	"github.com/genjidb/genji/cmd/genji/dbutil"
 	"github.com/urfave/cli/v2"
+
+	"github.com/genjidb/genji/cmd/genji/dbutil"
 )
 
 // NewInsertCommand returns a cli.Command for "genji insert".
@@ -33,7 +34,7 @@ Also you can use -a flag to create database automatically.
 This example will create a database with name 'data_${current unix timestamp}'
 It can be combined with --db to select an existing database but automatically create the table.
 
-$ genji insert -a -e bolt '[{"a": 1}, {"a": 2}]'
+$ genji insert -a '[{"a": 1}, {"a": 2}]'
 
 Insert can also insert a stream of objects or an array of objects from standard input:
 
@@ -64,7 +65,6 @@ $ curl https://api.github.com/repos/genjidb/genji/issues | genji insert --db myd
 			dbPath := c.String("db")
 			table := c.String("table")
 			args := c.Args().Slice()
-
 			return runInsertCommand(c.Context, dbPath, table, c.Bool("auto"), args)
 		},
 	}
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`},