squirrel
squirrel copied to clipboard
insert using select that has a non string column
Hello,
DB Fiddle for the example: https://www.db-fiddle.com/f/wpNmAGWfjWoZS4goc8EWfc/0
I was trying to generate a SQL like -
INSERT INTO test(id, data_id, type, deleted_at)
SELECT 10, data_id, type, deleted_at
FROM test
WHERE id=7
using -
sourceID:=7
targetID:=10
sql, args, err := sb.Insert("test").
Columns("id", "data_id", "type", "deleted_at").
Select(
sb.Select(targetID, "data_id", "type", "deleted_at").From("test")
Where(squirrel.Eq{
"id": sourceID,
}),
).
ToSql()
when I realized that the select column needs to be of string type. Is there a way to generate this query where select is having a non string value. Or is there some other way to handle this use case?
Thank you for any help!