diff options
author | Dimitri Roche <dimroc@gmail.com> | 2019-01-26 09:16:35 -0500 |
---|---|---|
committer | Yasuhiro Matsumoto <mattn.jp@gmail.com> | 2019-02-11 00:48:28 +0900 |
commit | abc8991d4d4bb67031d3ee9e387f3e2a4006b567 (patch) | |
tree | e3efd8ad6c200bbf0b7bd0b59e43d0f6aaf52194 | |
parent | Merge pull request #679 from pocke/an-a (diff) | |
download | golite-abc8991d4d4bb67031d3ee9e387f3e2a4006b567.tar.gz golite-abc8991d4d4bb67031d3ee9e387f3e2a4006b567.tar.xz |
column types text, varchar, *char return as strings:
As opposed to []byte arrays. This brings sqlite closer
in line with other dbs like postgres, allowing downstream
consumers to assume the scanned value is string across underlying
dbs.
-rw-r--r-- | sqlite3.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -223,6 +223,7 @@ var SQLiteTimestampFormats = []string{ const ( columnDate string = "date" columnDatetime string = "datetime" + columnText string = "text" columnTimestamp string = "timestamp" ) @@ -2061,10 +2062,15 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error { t = t.In(rc.s.c.loc) } dest[i] = t + case columnText: + dest[i] = s default: - dest[i] = []byte(s) + if strings.Contains(strings.ToLower(rc.decltype[i]), "char") { + dest[i] = s + } else { + dest[i] = []byte(s) + } } - } } return nil |