-
Notifications
You must be signed in to change notification settings - Fork 75
Query with []int64 slice for Where int IN (?) #105
Comments
I assume SELECT ... FROM TableA, TableB WHERE id(TableA) == TableB.idA ... which perhaps solves your task. Other than that, implementing the proposal seems feasible to me through the native API. If it is at all possible to support the same thing while using the |
I wasn't sure how the sub-queries are handled internally, I assumed it would iterate the inner query and than pass the resulting slice to the outer My problem right now is, that ql refuses to take any sort of slice as an (ps: Yup, |
Correction - What I really wanted to write is, for example: SELECT x, y, z FROM Table A WHERE id() IN (
SELECT idA FROM TableB WHERE expression
) equals SELECT TableA.x, TableA.y, TableA.z
FROM TableA, TableB
WHERE id(TableA) == TableB.idA && expression Currently the version with I took a brief look and what concerns passing a slice to the |
Thanks for the clarification.
Yup, I came up to the same conclusion while doing research on how lib/pq supports this. In type int64slice []int64
func (a int64slice) Value() (driver.Value, error) {
ints := make([]string, len(a))
for i, v := range a {
ints[i] = strconv.FormatInt(v, 10)
}
return "{" + strings.Join(ints, ",") + "}", nil
} and then using the wrapped slice as an argument for a query like this: It feels like the I tried the same trick on ql but it currently can't reinterpret the string as an []int64, which is most likely not what we want anyway. Since ql is all in go land and also lives in the same memory as the application running the queries, I wonder if you could use the I'd like to experiment with this but I haven't found the time to look for the doorknob to ql's codebase yet. :) |
Hrm.. seeing the documentation on
Is everything else really thrown away in error is it just a baseline recommendation? |
Thank you very much for the pointers and ideas. I don't yet have any answers to your questions, though. I hope to make some progress though this weekend. (?) |
Hi,
since we have
SELECT ... From TableA WHERE id() in (SELECT idA from TableB Where ...)
, can we find a way to makeint IN (...)
take a parameter for...
?I think we could get away with restricting the use slice Exec arguments to just these places.
In code: I'd like to use just the last example, which currently throws:
sql: converting Exec argument #0's type: unsupported type []int64, a slice
The text was updated successfully, but these errors were encountered: