From abc8991d4d4bb67031d3ee9e387f3e2a4006b567 Mon Sep 17 00:00:00 2001 From: Dimitri Roche Date: Sat, 26 Jan 2019 09:16:35 -0500 Subject: 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. --- sqlite3.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sqlite3.go') 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 -- cgit v1.2.3 From ae5cbb218c63c58afbe7237343b8b3ef28723a4b Mon Sep 17 00:00:00 2001 From: Dimitri Roche Date: Sat, 26 Jan 2019 14:54:27 -0500 Subject: column_type SQLITE_TEXT returned as string by default --- sqlite3.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'sqlite3.go') diff --git a/sqlite3.go b/sqlite3.go index ac713d6..1cf9451 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -223,7 +223,6 @@ var SQLiteTimestampFormats = []string{ const ( columnDate string = "date" columnDatetime string = "datetime" - columnText string = "text" columnTimestamp string = "timestamp" ) @@ -2062,14 +2061,8 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error { t = t.In(rc.s.c.loc) } dest[i] = t - case columnText: - dest[i] = s default: - if strings.Contains(strings.ToLower(rc.decltype[i]), "char") { - dest[i] = s - } else { - dest[i] = []byte(s) - } + dest[i] = s } } } -- cgit v1.2.3