[Django] #29155: Using contains field lookup with Substr database function cause modification of second parameter of Substr

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #29155: Using contains field lookup with Substr database function cause modification of second parameter of Substr

Django
#29155: Using contains field lookup with Substr database function cause
modification of second parameter of Substr
-------------------------------------+-------------------------------------
               Reporter:  norac89    |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 My model:


 {{{
 class User(models.Model):
     field1 = models.Charfield(max_length=120)
     field2 = models.Charfield(max_length=120)
 }}}

 Tried querying the model to get User instances in which field2 start with
 the three first characters of field1.
 Tried the following:

 {{{
 User.objects.filter(field2__startswith=Substr(F('field1'), 1, 3))
 }}}

 I m getting the following error

 {{{
 psycopg2.DataError: invalid input syntax for integer: "1%"
 LINE 1: ...(REPLACE(REPLACE((SUBSTRING("test_user"."field1", '1%', 3)),...
 }}}

 The second parameter of the substr function seems to be replaced with
 '1%'.

--
Ticket URL: <https://code.djangoproject.com/ticket/29155>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/050.4e6aba39405b6e63587c6bff258327b8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29155: Using contains lookup with Substr causes modification of second parameter of Substr (was: Using contains field lookup with Substr database function cause modification of second parameter of Substr)

Django
#29155: Using contains lookup with Substr causes modification of second parameter
of Substr
-------------------------------------+-------------------------------------
     Reporter:  norac89              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (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
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * stage:  Unreviewed => Accepted


Old description:

> My model:
>

> {{{
> class User(models.Model):
>     field1 = models.Charfield(max_length=120)
>     field2 = models.Charfield(max_length=120)
> }}}
>
> Tried querying the model to get User instances in which field2 start with
> the three first characters of field1.
> Tried the following:
>
> {{{
> User.objects.filter(field2__startswith=Substr(F('field1'), 1, 3))
> }}}
>
> I m getting the following error
>
> {{{
> psycopg2.DataError: invalid input syntax for integer: "1%"
> LINE 1: ...(REPLACE(REPLACE((SUBSTRING("test_user"."field1", '1%',
> 3)),...
> }}}
>
> The second parameter of the substr function seems to be replaced with
> '1%'.
New description:

 My model:


 {{{
 class User(models.Model):
     field1 = models.CharField(max_length=120)
     field2 = models.CharField(max_length=120)
 }}}

 Tried querying the model to get User instances in which field2 start with
 the three first characters of field1.
 Tried the following:

 {{{
 User.objects.filter(field2__startswith=Substr(F('field1'), 1, 3))
 }}}

 I m getting the following error

 {{{
 psycopg2.DataError: invalid input syntax for integer: "1%"
 LINE 1: ...(REPLACE(REPLACE((SUBSTRING("test_user"."field1", '1%', 3)),...
 }}}

 The second parameter of the substr function seems to be replaced with
 '1%'.

--

Comment:

 I'm attaching a test for Django's test suite that fails (on PostgreSQL but
 not SQLite) as of ba37ee9ef882deb8e917f1cae0c586a0a275e731.

--
Ticket URL: <https://code.djangoproject.com/ticket/29155#comment:1>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.84a65ec5e8a8f56d823d33bdd74a6193%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29155: Using contains lookup with Substr causes modification of second parameter of Substr

Django
In reply to this post by Django
#29155: Using contains lookup with Substr causes modification of second parameter
of Substr
-------------------------------------+-------------------------------------
     Reporter:  norac89              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (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
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * Attachment "29155-test.diff" added.


--
Ticket URL: <https://code.djangoproject.com/ticket/29155>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.7de06d439d05760678b0f5a9fc1f3952%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29155: Using contains lookup with Substr causes modification of second parameter of Substr

Django
In reply to this post by Django
#29155: Using contains lookup with Substr causes modification of second parameter
of Substr
-------------------------------------+-------------------------------------
     Reporter:  norac89              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.0
  (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
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * cc: felixxm (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29155#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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.1daec746543bf305b13184301eb015a5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29155: Using contains lookup with Substr causes modification of second parameter of Substr

Django
In reply to this post by Django
#29155: Using contains lookup with Substr causes modification of second parameter
of Substr
-------------------------------------+-------------------------------------
     Reporter:  norac89              |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (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
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * status:  new => assigned
 * owner:  nobody => felixxm


--
Ticket URL: <https://code.djangoproject.com/ticket/29155#comment:3>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.dae1af50d2cb7eabacc1376848d11ae3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29155: Using contains lookup with Substr causes modification of second parameter of Substr

Django
In reply to this post by Django
#29155: Using contains lookup with Substr causes modification of second parameter
of Substr
-------------------------------------+-------------------------------------
     Reporter:  norac89              |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by felixxm):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/9762 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/29155#comment:4>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.f56f488ed3e114de19dd604461d07171%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29155: Using contains lookup with Substr causes modification of second parameter of Substr

Django
In reply to this post by Django
#29155: Using contains lookup with Substr causes modification of second parameter
of Substr
-------------------------------------+-------------------------------------
     Reporter:  norac89              |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

 * stage:  Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/29155#comment:5>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.798944b1c0bb5d8f119d3c0493de19d4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29155: Using contains lookup with Substr causes modification of second parameter of Substr

Django
In reply to this post by Django
#29155: Using contains lookup with Substr causes modification of second parameter
of Substr
-------------------------------------+-------------------------------------
     Reporter:  norac89              |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"feb683c4c2c5ecfb61e4cb490c3e357450c0c0e8" feb683c4]:
 {{{
 #!CommitTicketReference repository=""
 revision="feb683c4c2c5ecfb61e4cb490c3e357450c0c0e8"
 Fixed #29155 -- Fixed crash when database functions are used with pattern
 lookups.

 Thanks Tim Graham and Sergey Fedoseev for reviews.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29155#comment:6>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.36321990ad017929087504cc2671c45d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #29155: Using contains lookup with Substr causes modification of second parameter of Substr

Django
In reply to this post by Django
#29155: Using contains lookup with Substr causes modification of second parameter
of Substr
-------------------------------------+-------------------------------------
     Reporter:  norac89              |                    Owner:  felixxm
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  2.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

 In [changeset:"ba3078c92de6ea3017441c7f503f36e52973ac6b" ba3078c]:
 {{{
 #!CommitTicketReference repository=""
 revision="ba3078c92de6ea3017441c7f503f36e52973ac6b"
 Refs #29155 -- Fixed LookupTests.test_pattern_lookups_with_substr() crash
 on Oracle.

 Test introduced in feb683c4c2c5ecfb61e4cb490c3e357450c0c0e8 revealed
 unexpected behavior on Oracle that allows concatenating NULL with string.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29155#comment:7>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.7d782a9c248fe013d90c40d9aef193e2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.