diff options
| author | Jan Mercl <0xjnml@gmail.com> | 2020-09-21 18:36:03 +0200 | 
|---|---|---|
| committer | Jan Mercl <0xjnml@gmail.com> | 2020-09-21 18:36:03 +0200 | 
| commit | a4318db8c7fc62f25e9f78c434d2a2a54fc1f433 (patch) | |
| tree | 75ca9b87d1718048e6c3788f6d257c770efc7603 /sqlite.go | |
| parent | a6843eee0fb7784a88e1c4f8e386aba6551292ef (diff) | |
handle properly 0 rows query results, fixes #28v1.7.1
Diffstat (limited to 'sqlite.go')
| -rw-r--r-- | sqlite.go | 12 | 
1 files changed, 12 insertions, 0 deletions
@@ -29,6 +29,7 @@ var (  	//lint:ignore SA1019 TODO implement QueryerContext  	_ driver.Queryer = (*conn)(nil)  	_ driver.Result  = (*result)(nil) +	_ driver.Rows    = noRows{}  	_ driver.Rows    = (*rows)(nil)  	_ driver.Stmt    = (*stmt)(nil)  	_ driver.Tx      = (*tx)(nil) @@ -496,6 +497,11 @@ func (s *stmt) query(ctx context.Context, args []driver.NamedValue) (r driver.Ro  				pstmt = 0  				return nil  			case sqlite3.SQLITE_DONE: +				if r == nil { +					pstmt = 0 +					r = noRows{} +					return nil +				}  				// nop  			default:  				return s.c.errstr(int32(rc)) @@ -516,6 +522,12 @@ func (s *stmt) query(ctx context.Context, args []driver.NamedValue) (r driver.Ro  	return r, err  } +type noRows struct{} + +func (noRows) Columns() []string         { return nil } +func (noRows) Close() error              { return nil } +func (noRows) Next([]driver.Value) error { return sql.ErrNoRows } +  type tx struct {  	c *conn  }  | 
