1
0
Fork 0

JSON types are also text

master
Philip O'Toole 5 years ago
parent 47c5e80af1
commit 3cfb0c3910

@ -11,6 +11,7 @@ This release uses a new Raft consensus version, with the move to Hashicorp Raft
- [PR #601](https://github.com/rqlite/rqlite/pull/601): By default use Raft network address as node ID. - [PR #601](https://github.com/rqlite/rqlite/pull/601): By default use Raft network address as node ID.
- [PR #602](https://github.com/rqlite/rqlite/pull/602): Add method to Store that returns leader ID. - [PR #602](https://github.com/rqlite/rqlite/pull/602): Add method to Store that returns leader ID.
- [PR #603](https://github.com/rqlite/rqlite/pull/603): Fix up status key name style. - [PR #603](https://github.com/rqlite/rqlite/pull/603): Fix up status key name style.
- [PR #604](https://github.com/rqlite/rqlite/pull/604): JSON types are also text.
## 4.6.0 (November 29th 2019) ## 4.6.0 (November 29th 2019)
_This release adds significant new functionality to the command-line tool, including much more control over backup and restore of the database. [Visit the Releases page](https://github.com/rqlite/rqlite/releases/tag/v4.6.0) to download this release._ _This release adds significant new functionality to the command-line tool, including much more control over backup and restore of the database. [Visit the Releases page](https://github.com/rqlite/rqlite/releases/tag/v4.6.0) to download this release._

@ -526,6 +526,7 @@ func normalizeRowValues(row []driver.Value, types []string) []interface{} {
// http://www.sqlite.org/datatype3.html // http://www.sqlite.org/datatype3.html
func isTextType(t string) bool { func isTextType(t string) bool {
return t == "text" || return t == "text" ||
t == "json" ||
t == "" || t == "" ||
strings.HasPrefix(t, "varchar") || strings.HasPrefix(t, "varchar") ||
strings.HasPrefix(t, "varying character") || strings.HasPrefix(t, "varying character") ||

@ -180,6 +180,30 @@ func Test_SimpleSingleStatements(t *testing.T) {
} }
} }
func Test_SimpleSingleJSONStatements(t *testing.T) {
db, path := mustCreateDatabase()
defer db.Close()
defer os.Remove(path)
_, err := db.Execute([]string{"CREATE TABLE foo (c0 VARCHAR(36), c1 JSON, c2 NCHAR, c3 NVARCHAR, c4 CLOB)"}, false, false)
if err != nil {
t.Fatalf("failed to create table: %s", err.Error())
}
_, err = db.Execute([]string{`INSERT INTO foo(c0, c1, c2, c3, c4) VALUES("fiona", '{"mittens": "foobar"}', "bob", "dana", "declan")`}, false, false)
if err != nil {
t.Fatalf("failed to insert record: %s", err.Error())
}
r, err := db.Query([]string{"SELECT * FROM foo"}, false, false)
if err != nil {
t.Fatalf("failed to query: %s", err.Error())
}
if exp, got := `[{"columns":["c0","c1","c2","c3","c4"],"types":["varchar(36)","json","nchar","nvarchar","clob"],"values":[["fiona","{\"mittens\": \"foobar\"}","bob","dana","declan"]]}]`, asJSON(r); exp != got {
t.Fatalf("unexpected results for query, expected %s, got %s", exp, got)
}
}
func Test_SimpleJoinStatements(t *testing.T) { func Test_SimpleJoinStatements(t *testing.T) {
db, path := mustCreateDatabase() db, path := mustCreateDatabase()
defer db.Close() defer db.Close()

Loading…
Cancel
Save