Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#33790 closed New feature (wontfix)

Add more database functions/aggregates.

Reported by: omid zarinmahd Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords: orm
Cc: omid zarinmahd Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi
I have a question regarding DjangoORM implementation :
you know this ORM supports some database functions that are really handy
but there are many functions in databases that Django ORM doesn't support
is there a reason behind this or do you guys have some plans?
some functions that Django ORM doesn't suppport in Postgresql:
cbrt()
div(y numeric, x numeric)
bit_xor()
bool_and()
covar_samp()
stddev_pop()
percentile_cont()
and there are more I just mentioned on database engine there are functions in Mysql that ORM doesn't support

Change History (3)

comment:1 by omid zarinmahd, 2 years ago

Cc: omid zarinmahd added

comment:2 by omid zarinmahd, 2 years ago

Version: 4.0dev

comment:3 by Mariusz Felisiak, 2 years ago

Resolution: wontfix
Status: newclosed
Summary: ORM functions suggestionAdd more database functions/aggregates.

Most of functions/aggregates mentioned in the ticket description are already included in Django:

  • bit_xor() -> django.contrib.postgres.aggregates.BitXor,
  • bool_and() -> django.contrib.postgres.aggregates.BoolAnd,
  • covar_samp() -> django.contrib.postgres.aggregates.CovarPop (with sample=True),
  • stddev_pop() -> django.db.models.StdDev.

As far as I'm aware after implementing #28643 we don't want to add more functions to the core unless they are common and supported by all backends. The current thread is to keep Django a core framework, not providing every utility which might be useful. You can write your own function, e.g.

class Cbrt(Transform):
    function = "CBRT"
    lookup_name = "cbrt"
Last edited 2 years ago by Mariusz Felisiak (previous) (diff)
Note: See TracTickets for help on using tickets.
Back to Top