Opened 4 years ago

Closed 19 months ago

#17027 closed New feature (fixed)

Let ExpressionNodes use __pow__

Reported by: dan@… Owned by: fhahn
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: flo@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Not sure what consequences this has for databases that don't support raising to powers, but I didn't see any exception handling for the +, -, /, %, etc so I didn't add it to this patch.

Please send any feedback.

Attachments (1)

add_pow_to_expression_node.diff (741 bytes) - added by dan@… 4 years ago.

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by dan@…

comment:1 Changed 4 years ago by Alex

  • Component changed from Uncategorized to Database layer (models, ORM)
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 2 years ago by fhahn

  • Cc flo@… added
  • Needs tests unset
  • Owner changed from nobody to fhahn
  • Patch needs improvement unset
  • Status changed from new to assigned
  • Version changed from 1.3 to master

I've updated the patch, added tests and created a pull request: https://github.com/django/django/pull/746

Oracle, Postgres and Mysql have a power function, but there isn't one in sqlite.

comment:3 Changed 19 months ago by timo

  • Triage Stage changed from Accepted to Ready for checkin

Pending a final ORM review, this looks good to me, and I've verified the tests are passing on all backends. Updated PR.

comment:4 Changed 19 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

In 5240b83462ba4887b67da8d493dfdc23fec5df97:

Fixed #17027 -- Added support for the power operator in F expressions.

Thanks dan at dlo.me for the initial patch.

  • Added pow and rpow to ExpressionNode
  • Added oracle and mysql specific power expressions
  • Added used-defined power function for sqlite
Note: See TracTickets for help on using tickets.
Back to Top