vertica/vertica-sql-go

error '??HELP??' binding timestamp as a parameter

Closed this issue · 1 comments

I got the following error trying to pass a timestamp as an argument using a structure with sqlx:
Error: [22007] Invalid input syntax for timestamp: "??HELP??"
Here is an example patch that seems to address the issue.
Note, I'm not using RFC3339Nano here because Vertica doesn't like timestamps we precision beyond what it supports.

diff --git a/vendor/github.com/watercraft/vertica-sql-go/msgs/febindmsg.go b/vendor/github.com/watercraft/vertica-sql-go/msgs/febindmsg.go
index 0b26c9d2..0326ce08 100644
--- a/vendor/github.com/watercraft/vertica-sql-go/msgs/febindmsg.go
+++ b/vendor/github.com/watercraft/vertica-sql-go/msgs/febindmsg.go
@@ -36,6 +36,7 @@ import (
        "database/sql"
        "database/sql/driver"
        "fmt"
+       "time"
 )
 
 // FEPBindMsg docs
@@ -78,6 +79,8 @@ func (m *FEBindMsg) Flatten() ([]byte, byte) {
                        } else {
                                strVal = "f"
                        }
+               case time.Time:
+                       strVal = v.Format("2006-01-02T15:04:05.999999Z07:00")
                case sql.NullBool, sql.NullFloat64, sql.NullInt64, sql.NullString:
                        buf.appendUint32(0xffffffff)
                        continue

Fixed in #59