-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SNOW-1510090: SNOW-1524103 Adding support for passing nil to variant columns #1170
Comments
hi there - as an alternative, would it be possible to try something like this #831 (comment) ? |
For our use case we do not have info on the data type of the columns we're trying to insert into. Hence it would be great if passing nil to a variant column would work as it does for other data types. |
tried one of the solutions for myself, which i suggested above
...
insertQuery := "INSERT INTO test_db.public.go1170 (c1) SELECT (?)"
fmt.Printf("Inserting VARIANT into table: %v\n", insertQuery)
_, err = conn.ExecContext(ctx, insertQuery,
// nil, --> this is indeed mapped to TEXT
sql.NullInt64{}, // --> this is not
)
if err != nil {
log.Fatalf("failed to run the query. %v, err: %v", insertQuery, err)
}
I was able to insert null value into |
Currently we are inserting null in all other data types using nil.. would it be possible to replace nil with sql.NullInt64{} without running into any issues for all the other data types? Also, are there plans to add support for nil binding for variant columns in the future? |
Hi @sahilsalim99 ! Variants are quite specific, because they can contain anything. It can be a string, an int or an object. If you just want to insert
|
What is the current behavior?
My code
_, err = db.ExecContext(ctx, "INSERT INTO test_variant SELECT ?", nil)
The above results in
What is the desired behavior?
Being able to pass nil to variant columns while binding
How would this improve
gosnowflake
?It would make it easier to work with variant columns.
The current workaround we're making use of involves wrapping it with a TRY_PARSE_JSON/PARSE_JSON :
_, err = db.ExecContext(ctx, "INSERT INTO test_variant SELECT TRY_PARSE_JSON(?)", nil)
The text was updated successfully, but these errors were encountered: