#23363: Field length in ORM
-------------------------------------+-------------------------------------
     Reporter:  qurben               |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  1.6
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |  worksforme
     Keywords:  ORM, order_by,       |             Triage Stage:
  QuerySet                           |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by jarshwah):

 I don't think custom lookups and transforms works for this use case. The
 ticket reporter wants to include that information in the select list.
 Transforms and Lookups are only really used in filter clauses at the
 moment.

 There is a PR that will allow this kind of functionality here:
 https://github.com/django/django/pull/2496

 And to implement the length function, you'd create an object such as:

 {{{
 class Length(Func):
     function = 'LENGTH'

     def as_mssql(self, compiler, query):
         self.function = 'LEN'
         return super(Length, self).as_sql(compiler, query)

     MyModel.objects.annotate(length=Length('myfield'))
 }}}

 I'm reopening on the basis that lookups and transforms don't solve the
 problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/23363#comment:2>
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.f8c98a78e1c482886d43ca36562fdb4d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to