squirrel
squirrel copied to clipboard
Inserting array value on postgresql
I want to insert array to the table , the following code does not work.
insertMap := map[string]interface{}{
order_column_id: input.OrderID,
order_column_assigned_users: []string{userID},
}
query, args, err := sq.Insert(ORDER_TABLE).
SetMap(insertMap).
PlaceholderFormat(sq.Dollar).
ToSql()
Please help me on:
- make the proper query to insert array
- i'm quite confused on how sq.Expr work , why does it does not work as expected?
EDIT:
insertMap := map[string]interface{}{
order_column_id: input.OrderID,
order_column_assigned_users: sq.Expr("ARRAY[?]", userID),
}
works but notice that if i use .Insert.Values(orderID , sq.Expr("ARRAY[?]",userID) )
It does not work.