diff options
author | drh <drh@noemail.net> | 2017-06-26 18:42:23 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2017-06-26 18:42:23 +0000 |
commit | d5fbde80a2ecb0ceaadb09804e1e9af2586de9f9 (patch) | |
tree | d2d3461e80f5ad74a521454b4ddb73a3560a820a /test | |
parent | a22dd3860a3491d621fec0d0d507c7a0a60d9b6b (diff) | |
download | sqlite-d5fbde80a2ecb0ceaadb09804e1e9af2586de9f9.tar.gz sqlite-d5fbde80a2ecb0ceaadb09804e1e9af2586de9f9.zip |
The ".import" command of the shell, and the csv virtual table extension both
ignore a single UTF-8 BOM at the beginning of their input.
FossilOrigin-Name: 7c15d762d99c2e3e534cd35dfe25ddcd317637eb1f2655fd24c2dd5f9d5a7613
Diffstat (limited to 'test')
-rw-r--r-- | test/shell5.test | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/test/shell5.test b/test/shell5.test index bb2511a52..62b91ffa8 100644 --- a/test/shell5.test +++ b/test/shell5.test @@ -184,6 +184,36 @@ do_test shell5-1.4.10.2 { catchcmd "test.db" {SELECT b FROM t1 WHERE a='7';} } {0 {Now is the time for all good men to come to the aid of their country.}} +# import file with 2 rows, 2 columns and an initial BOM +# +do_test shell5-1.4.11 { + set in [open shell5.csv wb] + puts $in "\xef\xbb\xbf2|3" + puts $in "4|5" + close $in + set res [catchcmd "test.db" {CREATE TABLE t2(x INT, y INT); +.import shell5.csv t2 +.mode quote +.header on +SELECT * FROM t2;}] + string map {\n | \n\r |} $res +} {0 {'x','y'|2,3|4,5}} + +# import file with 2 rows, 2 columns or text with an initial BOM +# +do_test shell5-1.4.12 { + set in [open shell5.csv wb] + puts $in "\xef\xbb\xbf\"two\"|3" + puts $in "4|5" + close $in + set res [catchcmd "test.db" {DELETE FROM t2; +.import shell5.csv t2 +.mode quote +.header on +SELECT * FROM t2;}] + string map {\n | \n\r |} $res +} {0 {'x','y'|'two',3|4,5}} + # check importing very long field do_test shell5-1.5.1 { set str [string repeat X 999] @@ -210,7 +240,8 @@ do_test shell5-1.6.1 { set in [open shell5.csv w] puts $in $data close $in - set res [catchcmd "test.db" {.import shell5.csv t2 + set res [catchcmd "test.db" {DROP TABLE IF EXISTS t2; +.import shell5.csv t2 SELECT COUNT(*) FROM t2;}] } {0 1} |