This PR allows users to pass map arguments to the query. The maps must have a key type of kind reflect.String. Maps a treated in a similar way to structs.
For inputs one can write in the query x = $M.key and then pass a map called M with key key and the value stored there will be passed to the database as the argument.
For outputs one can either write (col1, col2) AS &M.* or &M.col1. Here, the result columns will be stored with key col1/col2 in the map passed to Decode.
We also add a type sqlair.M = map[string]any that is of a valid type to be used with sqlair.
This PR allows users to pass map arguments to the query. The maps must have a key type of kind
reflect.String
. Maps a treated in a similar way to structs.For inputs one can write in the query
x = $M.key
and then pass a map called M with keykey
and the value stored there will be passed to the database as the argument.For outputs one can either write
(col1, col2) AS &M.*
or&M.col1
. Here, the result columns will be stored with keycol1
/col2
in the map passed toDecode
.We also add a type
sqlair.M = map[string]any
that is of a valid type to be used withsqlair
.