gocraft / dbr

Additions to Go's database/sql for super fast performance and convenience.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal: use Builder constructors for aggregate functions

amwolff-samsung opened this issue · comments

Currently, to use aggregate functions while building the query, we would do it this way:

Select("COUNT(CustomerID)").From("Customers").GroupBy("Country").Having(dbr.Gt("COUNT(CustomerID)", 5))

I was thinking whether we could add Builder statements for aggregate functions, so dbr will interpolate them for appropriate dialect.

agg := dbr.Count("CustomerID")
Select(agg).From("Customers").GroupBy("Country").Having(dbr.Gt(agg, 5))

Are PRs welcome? If so, I would be more than happy to add the functionality.

cc: @r-grodzki

commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.