mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
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
This commit is contained in:
@ -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}
|
||||
|
||||
|
Reference in New Issue
Block a user