Refs #28643 -- Added LTrim, RTrim, and Trim database functions.

Thanks Tim Graham and Mads Jensen for reviews.
This commit is contained in:
Mariusz Felisiak 2018-03-15 20:57:23 +01:00 committed by GitHub
parent 47bb3b68ff
commit 9421aee35e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 104 additions and 7 deletions

View file

@ -110,6 +110,11 @@ class Lower(Transform):
lookup_name = 'lower'
class LTrim(Transform):
function = 'LTRIM'
lookup_name = 'ltrim'
class Ord(Transform):
function = 'ASCII'
lookup_name = 'ord'
@ -136,6 +141,11 @@ class Right(Left):
return Substr(self.source_expressions[0], self.source_expressions[1] * Value(-1))
class RTrim(Transform):
function = 'RTRIM'
lookup_name = 'rtrim'
class StrIndex(Func):
"""
Return a positive integer corresponding to the 1-indexed position of the
@ -174,6 +184,11 @@ class Substr(Func):
return super().as_sql(compiler, connection, function='SUBSTR')
class Trim(Transform):
function = 'TRIM'
lookup_name = 'trim'
class Upper(Transform):
function = 'UPPER'
lookup_name = 'upper'