-
Notifications
You must be signed in to change notification settings - Fork 19
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
Can't bind to object types #10
Comments
I did some digging, and this is not supported at the moment. I'm trying to figure something out. Heres the problem: Crate object inserts is not actually supported via sql, so something like:
Would fail, it only supports object inserts via prepared statements via its rest api, so we need to send it a post like so:
And this is what this is what we do, but you probably already know this. I would like for us to be able to do something like this: type Metadata struct {
Count int `json:"count"`
}
stmt, _ := db.Prepare("insert into test (metadata) values (?)")
_, err := db.Exec(&Metadata{Count: 1}) The problem is that go's I'm not sure how I will support this though, since go's I'll open an issue with them, to see how can we solve this. |
Thanks. Few things: The object literal syntax is supported but it's not JSON-style. It's a custom format like:
But, yea, can't bind that and there's no array bindings:
What would be great (for us) is:
Struct-bindings would be great for strict objects and map-bindings for dynamic objects. For map-bindings and batching, the Cassandra driver might be inspirational. It's a little cumbersome but does provide the support. Also, personally, I think batching is a much more enticing feature than just binds alone. In fact, we wouldn't even using binds unless we can batch insert using them. Which is also why I didn't use prepared statements. That is, it appears not to support batch inserts, but I suppose I should have actually verified that. I'll keep digging too. For now, we have a workaround. It's not elegant but it works. |
@nicerobot I opened an issue about this in Go. Maybe this could be supported as soon as Go's 1.8 release. I think we should wait for it. If it doesn't come, we could start providing a new client package with our own interfaces for using crate, it would also have support for blobs & batching. |
Any update for this? |
Trying to insert into a
<columnName> object
usingthrows
when
value
is astring
.How do I insert objects using binds?
The text was updated successfully, but these errors were encountered: