aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Roche <dimroc@gmail.com>2019-01-26 09:16:35 -0500
committerYasuhiro Matsumoto <mattn.jp@gmail.com>2019-02-11 00:48:28 +0900
commitabc8991d4d4bb67031d3ee9e387f3e2a4006b567 (patch)
treee3efd8ad6c200bbf0b7bd0b59e43d0f6aaf52194
parentMerge pull request #679 from pocke/an-a (diff)
downloadgolite-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.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/sqlite3.go b/sqlite3.go
index f731d20..ac713d6 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -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