Closed d0zer11st closed 4 weeks ago
I'll take a look
I've made some changes in #228 that should fix this @d0zer11st. It changes how functions are modified, but this should be better overall.
selectQuery := psql.Select(
sm.From(models.TableNames.Examples),
sm.Columns(
models.ColumnNames.Examples.Hostname,
psql.F(
"count",
"*",
)(
fm.Filter(models.ExampleWhere.ID.GT(0)),
fm.As("non_zero_ids"),
),
),
sm.GroupBy("hostname"),
)
Try it out and let me know what you think.
@stephenafamo thank you for quick response. That works for me.
I noticed, psql.F(...)().As("name")
still works, will this notation be deprecated ?
I noticed,
psql.F(...)().As("name")
still works, will this notation be deprecated ?
Unlikely.
For ease of use, *dialect.Function
embeds dialect.Expression
. This makes it easy to fluently chain expressions involving function. For example:
HAVING count(1) > 2
sm.Having(psql.F("count", 1).GT(psql.Raw(2))
This is more annoying to do without embedding, but dialect.Expression
also has an As()
method.
The fm.As()
mod instead is specifically to support some syntax when using a function as the source of a SELECT
query.
I'll see if there is a way to reduce duplication
got you. thanks
I'm getting wrong SQL query using query builder for "FilterWhere".
There is extra "OVER ()" keyword in result query.
how to reproduce:
Got:
Expected: