Open makholm opened 3 years ago
Is there a way to alias a boolean expression in the select column list?
I think what I want is basically:
db.From("foo").Select(goqu.I("foo.bar").IsNotNull().As("have_bar")
But type exp.BooleanExpression does not implement As(). I can work around it using a functional expression. This generates the correct SQL, though with extra parenthesis:
Select(goqu.Func("", goqu.I("foo.bar").IsNotNull()).As("have_bar"))
...but I'm hoping there's prettier way that doesn't involve abusing Func()...
Func()
@makholm hi, try this
goqu.From("foo").Select( goqu.L(`foo.bar IS NOT NULL`).As("some_field"), )
Is there a way to alias a boolean expression in the select column list?
I think what I want is basically:
But type exp.BooleanExpression does not implement As(). I can work around it using a functional expression. This generates the correct SQL, though with extra parenthesis:
...but I'm hoping there's prettier way that doesn't involve abusing
Func()
...