-
Notifications
You must be signed in to change notification settings - Fork 63
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
Support bytes #75
base: master
Are you sure you want to change the base?
Support bytes #75
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,7 @@ When passing arguments to queries, the driver supports the following Go data typ | |
* integers | ||
* `bool` | ||
* `string` | ||
* `bytes` | ||
* slices | ||
* `trino.Numeric` - a string representation of a number | ||
* `time.Time` - passed to Trino as a timestamp with a time zone | ||
|
@@ -255,7 +256,10 @@ will receive a `[]interface{}` slice, with values of the following types: | |
* `json.Number` for any numeric Trino types | ||
* `[]interface{}` for Trino arrays | ||
* `map[string]interface{}` for Trino maps | ||
* `string` for other Trino types, as character, date, time, or timestamp | ||
* `string` for other Trino types, as character, date, time, varbinary or timestamp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section is about reading data from Trino. We discussed this in another comment that support for []byte will be added in a separate PR, so remove this for now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh yes, it removed now |
||
|
||
**It should be noted that varbinary will be encoded using base64** | ||
|
||
|
||
## License | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
package trino | ||
|
||
import ( | ||
"encoding/hex" | ||
"encoding/json" | ||
"fmt" | ||
"reflect" | ||
|
@@ -147,9 +148,8 @@ func Serial(v interface{}) (string, error) { | |
case string: | ||
return "'" + strings.Replace(x, "'", "''", -1) + "'", nil | ||
|
||
// TODO - []byte should probably be matched to 'VARBINARY' in trino | ||
case []byte: | ||
return "", UnsupportedArgError{"[]byte"} | ||
return "X'" + strings.ToUpper(hex.EncodeToString(x)) + "'", nil | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds support for using Also, please update the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reading VARBINARY columns in query results we need to implement sql.Scanner interface.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would to like to try in this PR? I know I'm asking to extend the scope of work, so it's also ok to do this in a follow up PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will do this in next PR. I hope to also support driver.Valuer interface |
||
|
||
case trinoDate: | ||
return fmt.Sprintf("DATE '%04d-%02d-%02d'", x.year, x.month, x.day), nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bytes or []byte?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to []byte now