squirrel
squirrel copied to clipboard
Fluent SQL generation for golang
Hello,I have a problem. query := sq.Update("a").Set("orders", sq.Case("id").When("20027", "3")) _, err := query.RunWith(db).Exec() the err is : sql: converting argument $1 type: unsupported type squirrel.CaseBuilder, a struct How can I...
How can I generate a query like this using https://github.com/Masterminds/squirrel: ``` DELETE m FROM mainschema.maintable AS m LEFT JOIN (SELECT stagingid FROM stagingschema.stagingtable WHERE versionid= ?) AS s ON m.mainid...
``` package testing import ( "database/sql" "fmt" "testing" sq "github.com/Masterminds/squirrel" _ "github.com/lib/pq" "github.com/stretchr/testify/require" ) var psql = sq.StatementBuilder.PlaceholderFormat(sq.Dollar) func TestInsertSelect(t *testing.T) { driver, path := "postgres", "host=localhost sslmode=disable port=5432 user=postgres...
hi, import ( "fmt" sq "github.com/Masterminds/squirrel" "github.com/Masterminds/structable" ) func UpdateUserBalance(db sq.DBProxyBeginner, uid int, price int64) error { query := sq.Update(table).Set("balance", sq.Expr("? + ?", "balance", price)) query = query.Where(sq.Eq{"id": uid}) s,...
Fantastic work to all involved! I recently came across a need that was difficult to work around. We had queries taking much longer than expected after a DB version change....
I would like better management Limit, Offset via interface struct, for example via sqlizer. example func fnSqlizer(customLimit) squirrel.SqLizer{ return squirrel.Exp("LIMIT ?", 10) } selectBuilder.Limit(fnSqLizer(customLimit))
#102
This allows for deterministic testing of the resulting query when more than one predicate is added to the Builder.
We have a use-case where we need to be able to set the columns on a `SelectBuilder` after it has already been created. Example: ```go builder.SetColumns("biz", "baz") ```