sea-query icon indicating copy to clipboard operation
sea-query copied to clipboard

Expose arg_with

Open remiposo opened this issue 6 months ago • 3 comments

PR Info

  • Closes https://github.com/SeaQL/sea-query/issues/901

Changes

  • Changed arg_with to pub to specify FuncArgMod

remiposo avatar Jul 04 '25 06:07 remiposo

what do you need this method for? can you instead add a method similar to fn array_agg_distinct?

tyt2y3 avatar Jul 08 '25 08:07 tyt2y3

Thank you for your reply!

In my use case, I dynamically generate SQL with sea-query based on user requests. While I understand that actual use cases are limited, I want to allow users to use DISTINCT with aggregate functions like SUM / AVG as long as it's valid SQL. Is the reason you don't want to make args_with public to prevent invalid SQL from being generated for non-aggregate functions like ABS?

I could add xxx_distinct for all aggregate functions, but since I noticed that raw DISTINCT can be easily applied with cust_with_expr, I'm starting to feel that if there's less demand compared to count_distinct, it might not be worth adding specifically...

https://github.com/SeaQL/sea-query/blob/f778d36b7317a7851848115d7636099f2d177244/src/expr.rs#L1886-L1891

remiposo avatar Jul 08 '25 09:07 remiposo

sorry for the delay, if count_distinct is what you need, let's just add that specifically!

tyt2y3 avatar Aug 03 '25 22:08 tyt2y3