#28643: Complete the ORM Function Library
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: JunyiJ
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by felixxm:
Old description:
> I was surprised to learn that we didn't have a StrIndex function until
> version 2, and yet we had Substr since at least version 1.8. I wonder
> how users were using Substr without also finding a use for StrIndex this
> whole time. Anyway, since we seem to be adding these functions one at a
> time, why don't we work on trying to get the built-ins implemented in one
> sweep instead?
>
> We may even want to split the documentation page
> (https://docs.djangoproject.com/en/dev/ref/models/database-functions/)
> into further categories with String functions and Numeric functions.
>
> This is just a sample checklist. There are probably several more that I
> have missed. These functions are available directly out of the box with
> PostgreSQL.
>
> String functions not yet implemented:
> ASCII(): Returns numeric value of left-most character
> CHR(): Character with the given code.
> LEFT(): Returns the leftmost number of characters as specified
> LPAD(): Returns the string argument, left-padded with the specified
> string
> LTRIM(): Removes leading spaces
> MD5(): Calculates the MD5 hash of string, returning the result in
> hexadecimal
> REPEAT(): Repeats a string the specified number of times
> REPLACE(): Replaces occurrences of a specified string
> REVERSE(): Reverse the characters in a string
> RIGHT(): Returns the specified rightmost number of characters
> RPAD(): Appends string the specified number of times
> RTRIM(): Removes trailing spaces
> TRIM(): Removes leading and trailing spaces
>
> Numeric functions:
> ABS(): Returns the absolute value.
> ACOS(): Returns the arccosine.
> ASIN(): Returns the arcsine.
> ATAN(): Returns the arctangent.
> ATAN2(): Returns the arctangent of the two variables passed to it.
> CEILING(): Returns the smallest integer value that is not less than a
> numeric expression
> COS(): Returns the cosine expressed in radians.
> COT(): Returns the cotangent.
> DEGREES(): Returns a numeric expression converted from radians to
> degrees.
> EXP(): Returns the base of the natural logarithm (e) raised to the power
> of a numeric expression.
> FLOOR(): Returns the largest integer value that is not greater than a
> numeric expression.
> LOG(): Returns the natural logarithm of a numeric expression.
> MOD(): Returns the remainder of one expression by diving by another
> expression.
> PI(): Returns the value of pi
> POWER(): Returns the value of one expression raised to the power of
> another expression
> RADIANS(): Returns the value of an expression converted from degrees to
> radians.
> ROUND(): Returns a numeric expression rounded to an integer. Can be used
> to round an expression to a number of decimal points
> SIN(): Returns the sine given in radians.
> SQRT(): Returns the square root.
> TAN(): Returns the tangent expressed in radians.
New description:
I was surprised to learn that we didn't have a StrIndex function until
version 2, and yet we had Substr since at least version 1.8. I wonder how
users were using Substr without also finding a use for StrIndex this whole
time. Anyway, since we seem to be adding these functions one at a time,
why don't we work on trying to get the built-ins implemented in one sweep
instead?
We may even want to split the documentation page
(https://docs.djangoproject.com/en/dev/ref/models/database-functions/)
into further categories with String functions and Numeric functions.
This is just a sample checklist. There are probably several more that I
have missed. These functions are available directly out of the box with
PostgreSQL.
String functions not yet implemented:
ASCII(): Returns numeric value of left-most character
CHR(): Character with the given code.
LEFT(): Returns the leftmost number of characters as specified
LPAD(): Returns the string argument, left-padded with the specified string
MD5(): Calculates the MD5 hash of string, returning the result in
hexadecimal
REPEAT(): Repeats a string the specified number of times
REPLACE(): Replaces occurrences of a specified string
REVERSE(): Reverse the characters in a string
RIGHT(): Returns the specified rightmost number of characters
RPAD(): Appends string the specified number of times
LTRIM(): Removes leading spaces
([https://github.com/django/django/pull/9220 PR #9220])
RTRIM(): Removes trailing spaces
([https://github.com/django/django/pull/9220 PR #9220])
TRIM(): Removes leading and trailing spaces
([https://github.com/django/django/pull/9220 PR #9220])
Numeric functions:
ABS(): Returns the absolute value.
ACOS(): Returns the arccosine.
ASIN(): Returns the arcsine.
ATAN(): Returns the arctangent.
ATAN2(): Returns the arctangent of the two variables passed to it.
CEILING(): Returns the smallest integer value that is not less than a
numeric expression
COS(): Returns the cosine expressed in radians.
COT(): Returns the cotangent.
DEGREES(): Returns a numeric expression converted from radians to degrees.
EXP(): Returns the base of the natural logarithm (e) raised to the power
of a numeric expression.
FLOOR(): Returns the largest integer value that is not greater than a
numeric expression.
LOG(): Returns the natural logarithm of a numeric expression.
MOD(): Returns the remainder of one expression by diving by another
expression.
PI(): Returns the value of pi
POWER(): Returns the value of one expression raised to the power of
another expression
RADIANS(): Returns the value of an expression converted from degrees to
radians.
ROUND(): Returns a numeric expression rounded to an integer. Can be used
to round an expression to a number of decimal points
SIN(): Returns the sine given in radians.
SQRT(): Returns the square root.
TAN(): Returns the tangent expressed in radians.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/28643#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.7705f70c03da6304a954c21428ee6d3c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.