diff options
author | 2024-08-15 00:30:58 +0000 | |
---|---|---|
committer | 2024-08-15 00:30:58 +0000 | |
commit | 586639ccf0e2fefbd1da2c59d5abcb8d64d37434 (patch) | |
tree | 52a9d7412e98ef406c39f09a6fad6e3fa7a7ad49 /vendor/github.com/ncruces/go-sqlite3/stmt.go | |
parent | update go-ffmpreg to v0.2.5 (pulls in latest tetratelabs/wazero) (#3203) (diff) | |
download | gotosocial-586639ccf0e2fefbd1da2c59d5abcb8d64d37434.tar.xz |
update go-sqlite3 to v0.18.0 (#3204)
Diffstat (limited to 'vendor/github.com/ncruces/go-sqlite3/stmt.go')
-rw-r--r-- | vendor/github.com/ncruces/go-sqlite3/stmt.go | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/vendor/github.com/ncruces/go-sqlite3/stmt.go b/vendor/github.com/ncruces/go-sqlite3/stmt.go index 381a7d06b..8e6ad2c10 100644 --- a/vendor/github.com/ncruces/go-sqlite3/stmt.go +++ b/vendor/github.com/ncruces/go-sqlite3/stmt.go @@ -15,6 +15,7 @@ import ( type Stmt struct { c *Conn err error + sql string handle uint32 } @@ -29,6 +30,15 @@ func (s *Stmt) Close() error { } r := s.c.call("sqlite3_finalize", uint64(s.handle)) + for i := range s.c.stmts { + if s == s.c.stmts[i] { + l := len(s.c.stmts) - 1 + s.c.stmts[i] = s.c.stmts[l] + s.c.stmts[l] = nil + s.c.stmts = s.c.stmts[:l] + break + } + } s.handle = 0 return s.c.error(r) @@ -41,6 +51,24 @@ func (s *Stmt) Conn() *Conn { return s.c } +// SQL returns the SQL text used to create the prepared statement. +// +// https://sqlite.org/c3ref/expanded_sql.html +func (s *Stmt) SQL() string { + return s.sql +} + +// ExpandedSQL returns the SQL text of the prepared statement +// with bound parameters expanded. +// +// https://sqlite.org/c3ref/expanded_sql.html +func (s *Stmt) ExpandedSQL() string { + r := s.c.call("sqlite3_expanded_sql", uint64(s.handle)) + sql := util.ReadString(s.c.mod, uint32(r), _MAX_SQL_LENGTH) + s.c.free(uint32(r)) + return sql +} + // ReadOnly returns true if and only if the statement // makes no direct changes to the content of the database file. // @@ -283,7 +311,8 @@ func (s *Stmt) BindNull(param int) error { // // https://sqlite.org/c3ref/bind_blob.html func (s *Stmt) BindTime(param int, value time.Time, format TimeFormat) error { - if format == TimeFormatDefault { + switch format { + case TimeFormatDefault, TimeFormatAuto, time.RFC3339Nano: return s.bindRFC3339Nano(param, value) } switch v := format.Encode(value).(type) { |