mirror of
https://github.com/ncruces/go-sqlite3.git
synced 2026-01-12 05:59:14 +00:00
Improved quoting.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"math"
|
||||
"reflect"
|
||||
"testing"
|
||||
@@ -19,8 +21,8 @@ func TestQuote(t *testing.T) {
|
||||
{`a'bc`, "'a''bc'"},
|
||||
{"\x07bc", "'\abc'"},
|
||||
{"\x1c\n", "'\x1c\n'"},
|
||||
{"\xB0\x00\x0B", "'\xB0'"},
|
||||
{[]byte("\xB0\x00\x0B"), "x'B0000B'"},
|
||||
{"\xB0\x00\x0B", ""},
|
||||
|
||||
{0, "0"},
|
||||
{true, "1"},
|
||||
@@ -33,7 +35,13 @@ func TestQuote(t *testing.T) {
|
||||
{int64(math.MaxInt64), "9223372036854775807"},
|
||||
{time.Unix(0, 0).UTC(), "'1970-01-01T00:00:00Z'"},
|
||||
{sqlite3.ZeroBlob(4), "x'00000000'"},
|
||||
{sqlite3.ZeroBlob(1e9), ""},
|
||||
{int8(0), "0"},
|
||||
{uint(0), "0"},
|
||||
{float32(0), "0"},
|
||||
{(*string)(nil), "NULL"},
|
||||
{json.Number("0"), "'0'"},
|
||||
{&sql.RawBytes{'0'}, "x'30'"},
|
||||
{t, ""}, // panic
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
@@ -62,7 +70,7 @@ func TestQuoteIdentifier(t *testing.T) {
|
||||
{`a'bc`, `"a'bc"`},
|
||||
{"\x07bc", "\"\abc\""},
|
||||
{"\x1c\n", "\"\x1c\n\""},
|
||||
{"\xB0\x00\x0B", ""},
|
||||
{"\xB0\x00\x0B", ""}, // panic
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user