Short back history:
I've been using Go for just a short while now and already it has
displaced Python as my go-to language for writing something quickly. I
absolutely love working in Go!
A few months ago I decided to start trying to write some simple
utilities to help us manage our customers' databases. As all of our
database connections are done using ODBC, a quick search resulted in
two:
* godbc -
http://github.com/BenoyRNair/godbc/
* go-odbc -
https://github.com/weigj/go-odbc
The first has all but been abandoned and the second didn't compile (at
the time) in the latest release of Go. After some tweaks I finally did
get it to compile, but quickly learned that it has some rather leaky
abstractions. The underlying C types are quite often exposed and I
caused several panics while trying to bind parameters.
Shortly after these frustrations, I discovered exp/sql and decided to
create an ODBC driver for it. After some holiday distractions, I sat
down for a few latish nights and came up with mgodbc (https://
bitbucket.org/miquella/mgodbc/). I'm still missing the time
integration and I might need to change a thing or two about the
implementation (I've only tested it on 32-bit Windows...), but it's
been much easier to work with than the others I've tried (granted,
this may just be because I wrote it!).
----
This brings me to my questions:
1. While writing the driver, I noted that the documentation states
that strings cannot be returned by the driver.Rows.Next() function.
Why is that?
2. Why is it not possible to use **int or **string to receive nullable
fields in sql.Rows.Next()?
For example:
rows, err := db.Query("SELECT
t.id,
rel.id,
rel.name FROM t LEFT
OUTER JOIN rel ...")
...
for rows.Next() {
var id int
var relID *int
var relName string
err = rows.Scan(&id, &relID, &relName)
}
3. Has there been any consideration to having an interface that can be
implemented to deserialize a row directly into an object rather than
having to query all of the fields through sql.Rows.Next() and then
populate the object?
I apologize for the lengthy post, these questions have been swimming
around my head for several days... But thank you for any answers you
may have!