From 188d28f054dbc9d8897a99d2213d8895922fc330 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:46:23 +0200 Subject: [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] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .../github.com/ncruces/go-sqlite3/driver/driver.go | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'vendor/github.com/ncruces/go-sqlite3/driver/driver.go') 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) -- cgit v1.2.3