Closed
Description
*What does 'go version' print?* go version go1.3 darwin/amd64 *What steps reproduce the problem?* See attached sample. It needs Postgres to run, but another DB should work just as well, there shouldn't be driver-dependent code involved. *What happened?* Panic in case 6 in the sample program. {{{ panic: value method main.MyType.Value called using nil *MyType pointer goroutine 16 [running]: runtime.panic(0x1c1980, 0xc208000960) /usr/local/Cellar/go/1.3/libexec/src/pkg/runtime/panic.c:279 +0xf5 main.(*MyType).Value(0x0, 0x0, 0x0, 0x0, 0x0) <autogenerated>:1 +0x97 database/sql/driver.defaultConverter.ConvertValue(0x2053a0, 0x0, 0x0, 0x0, 0x0, 0x0) /usr/local/Cellar/go/1.3/libexec/src/pkg/database/sql/driver/types.go:219 +0x101 database/sql.driverArgs(0x0, 0xc208095f20, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0) /usr/local/Cellar/go/1.3/libexec/src/pkg/database/sql/convert.go:35 +0x1e1 database/sql.(*DB).exec(0xc208054100, 0x28a1f0, 0x1b, 0xc208095f20, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0) /usr/local/Cellar/go/1.3/libexec/src/pkg/database/sql/sql.go:884 +0x1ec database/sql.(*DB).Exec(0xc208054100, 0x28a1f0, 0x1b, 0xc208095f20, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0) /usr/local/Cellar/go/1.3/libexec/src/pkg/database/sql/sql.go:866 +0xd4 main.main() /Users/alex/g/main.go:60 +0x6b5 }}} *What should have happened instead?* Behaviour of Exec() when handling nil pointers of values that implement sql.Valuer should be consistent with primitive values. I can insert a pointer to string, and if it's nil, it will translate to SQL NULL just fine.
Attachments:
- main.go (996 bytes)