Merge pull request #1 from jnesss/time-fix

Add time.Time support to Go driver parameter binding
This commit is contained in:
Jonathan Ness
2025-05-03 15:36:10 -07:00
committed by GitHub

View File

@@ -4,6 +4,7 @@ import (
"database/sql/driver"
"fmt"
"runtime"
"time"
"unsafe"
)
@@ -244,6 +245,12 @@ func buildArgs(args []driver.Value) ([]limboValue, func(), error) {
blob := makeBlob(val)
pinner.Pin(blob)
*(*uintptr)(unsafe.Pointer(&limboVal.Value)) = uintptr(unsafe.Pointer(blob))
case time.Time: // Add this case
limboVal.Type = textVal
timeStr := val.Format(time.RFC3339)
cstr := CString(timeStr)
pinner.Pin(cstr)
*(*uintptr)(unsafe.Pointer(&limboVal.Value)) = uintptr(unsafe.Pointer(cstr))
default:
return nil, pinner.Unpin, fmt.Errorf("unsupported type: %T", v)
}