Closed ctengiz closed 5 years ago
I believe I am running into this too, it seems to be treating the nil's as empty strings, if i do one with just a few parameters however it works fine
Ok I wrote up a little test, it happens after 8 parameters, so the 9th parameter fails. If you add this to driver_test.go you can see it fails reliably.
func TestGoIssue80(t *testing.T) {
temppath := TempFileName("test_issue80_")
conn, err := sql.Open("firebirdsql_createdb", "sysdba:masterkey@localhost:3050"+temppath)
if err != nil {
t.Fatalf("Error occured at sql.Open()")
}
defer conn.Close()
query := `
CREATE TABLE foo (
a INT,
b INT,
c INT,
d INT,
e INT,
f INT,
g INT,
h INT,
i INT
)
`
_, err = conn.Exec(query) if err != nil {
t.Error(err)
}
_, err = conn.Exec(
"insert into foo(a, b, c, d, e, f, g, h, i) values (?, ?, ? ,?, ?, ?, ?, ?, ?)", nil, nil, nil, nil, nil, nil, nil, nil, nil)
if err != nil {
t.Error(err)
}
}
Some thoughts on the test, this test is hard coded to just what it takes to fail. It might be a good idea to modify the test to allow a dynamic number of parameters to make it easier to test that the fix doesn't just correct it for 9 parameters but for any arbitrarily large number, like 20-30 parameters.
I merged @jacobalberty 's patch, thanks. Does this issue fixed ? @ctengiz
@nakagami I pulled the new one with my last patch into my real world usage aaand things broke. I found a new test case. I think some improvement on the test case could potentially be done. I am working on a new patch that i'm manually verifying against the binary from the resulting blr. the ultimate issue seems to be big.Int.Mod() changes the object you're calling it from to be the modulus so you're losing everything past the modulus when its called.
func TestGoIssue80(t *testing.T) {
temppath := TempFileName("test_issue80_")
conn, err := sql.Open("firebirdsql_createdb", "sysdba:masterkey@localhost:3050"+temppath)
if err != nil { t.Fatalf("Error occured at sql.Open()") } defer conn.Close()
query := ` CREATE TABLE foo ( a VARCHAR(10),
b VARCHAR(10),
c BIGINT, d INT, e INT,
f INT,
g INT,
h INT,
i INT,
j INT, k INT, l INT, m INT, n INT
) `
_, err = conn.Exec(query) if err != nil {
t.Error(err)
}
_, err = conn.Exec(
"insert into foo(a, b, c, d, e, f, g, h, i, j, k, l, m, n) values (?, ?, ? ,?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
" ", nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
if err != nil {
t.Error(err)
}
}
I think in there is a bug in paramsToBlr function, because with queries with more than 3 or 4 params, params are incorrectly bound. Please see the attached code. The code generates
conversion error from string ""
although there is no "" (empty string) value.Or am I missing something?
TIA