Skip to content

Using a function with custom types? #2603

Answered by andrewmbenton
tamis-laan asked this question in Q&A
Discussion options

You must be logged in to vote

As you can see for some reason the ST_GEOMFROMTEXT function is interpreted as a variable.

Not exactly. It's a bit confusing, but sqlc has simply picked a name for the parameter struct field based on the function name. If you aren't happy with the name, you can use sqlc.arg() to change it like this: ($1, $2, ST_GEOMFROMTEXT(sqlc.arg(location))).

Why does this happen? How can I deal with this?

I will assume by "this" you mean "the struct field for the location query parameter has type interface{} rather than types.PostGISPoint" since I've already addressed the naming issue above.

@orisano provides a good explanation above of the type inference issues involved. The ST_GEOMFROMTEXT functi…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
7 replies
@tamis-laan
Comment options

@orisano
Comment options

@tamis-laan
Comment options

@tamis-laan
Comment options

@orisano
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by andrewmbenton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants