summaryrefslogtreecommitdiff
path: root/vendor/github.com/ncruces/go-sqlite3/driver/driver.go
diff options
context:
space:
mode:
authorLibravatar dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2024-09-30 12:46:23 +0200
committerLibravatar GitHub <noreply@github.com>2024-09-30 12:46:23 +0200
commit188d28f054dbc9d8897a99d2213d8895922fc330 (patch)
tree2691665ad2e129ed7a07ea468024cc7db5005a54 /vendor/github.com/ncruces/go-sqlite3/driver/driver.go
parent[bugfix] Carry-over "PinnedAt" when refreshing status (#3373) (diff)
downloadgotosocial-188d28f054dbc9d8897a99d2213d8895922fc330.tar.xz
[chore]: Bump github.com/ncruces/go-sqlite3 from 0.18.3 to 0.18.4 (#3375)
Bumps [github.com/ncruces/go-sqlite3](https://github.com/ncruces/go-sqlite3) from 0.18.3 to 0.18.4. - [Release notes](https://github.com/ncruces/go-sqlite3/releases) - [Commits](https://github.com/ncruces/go-sqlite3/compare/v0.18.3...v0.18.4) --- updated-dependencies: - dependency-name: github.com/ncruces/go-sqlite3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/driver/driver.go')
-rw-r--r--vendor/github.com/ncruces/go-sqlite3/driver/driver.go34
1 files changed, 33 insertions, 1 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/driver/driver.go b/vendor/github.com/ncruces/go-sqlite3/driver/driver.go
index c6c758ac2..7e6fee9ea 100644
--- a/vendor/github.com/ncruces/go-sqlite3/driver/driver.go
+++ b/vendor/github.com/ncruces/go-sqlite3/driver/driver.go
@@ -578,8 +578,15 @@ type rows struct {
*stmt
names []string
types []string
+ nulls []bool
}
+var (
+ // Ensure these interfaces are implemented:
+ _ driver.RowsColumnTypeDatabaseTypeName = &rows{}
+ _ driver.RowsColumnTypeNullable = &rows{}
+)
+
func (r *rows) Close() error {
r.Stmt.ClearBindings()
return r.Stmt.Reset()
@@ -596,6 +603,22 @@ func (r *rows) Columns() []string {
return r.names
}
+func (r *rows) loadTypes() {
+ if r.nulls == nil {
+ count := r.Stmt.ColumnCount()
+ r.nulls = make([]bool, count)
+ r.types = make([]string, count)
+ for i := range r.nulls {
+ if col := r.Stmt.ColumnOriginName(i); col != "" {
+ r.types[i], _, r.nulls[i], _, _, _ = r.Stmt.Conn().TableColumnMetadata(
+ r.Stmt.ColumnDatabaseName(i),
+ r.Stmt.ColumnTableName(i),
+ col)
+ }
+ }
+ }
+}
+
func (r *rows) declType(index int) string {
if r.types == nil {
count := r.Stmt.ColumnCount()
@@ -608,7 +631,8 @@ func (r *rows) declType(index int) string {
}
func (r *rows) ColumnTypeDatabaseTypeName(index int) string {
- decltype := r.declType(index)
+ r.loadTypes()
+ decltype := r.types[index]
if len := len(decltype); len > 0 && decltype[len-1] == ')' {
if i := strings.LastIndexByte(decltype, '('); i >= 0 {
decltype = decltype[:i]
@@ -617,6 +641,14 @@ func (r *rows) ColumnTypeDatabaseTypeName(index int) string {
return strings.TrimSpace(decltype)
}
+func (r *rows) ColumnTypeNullable(index int) (nullable, ok bool) {
+ r.loadTypes()
+ if r.nulls[index] {
+ return false, true
+ }
+ return true, false
+}
+
func (r *rows) Next(dest []driver.Value) error {
old := r.Stmt.Conn().SetInterrupt(r.ctx)
defer r.Stmt.Conn().SetInterrupt(old)