#35262: Addindex operation generates wrong sql code for Postgresql GinIndex
----------------------------------+--------------------------------------
     Reporter:  pjuhen            |                    Owner:  nobody
         Type:  Bug               |                   Status:  new
    Component:  contrib.postgres  |                  Version:  5.0
     Severity:  Normal            |               Resolution:
     Keywords:                    |             Triage Stage:  Unreviewed
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+--------------------------------------
Changes (by Tim Graham):

 * component:  Uncategorized => contrib.postgres


Old description:

> Hi,
>
> I have created a Gin Index using the folowing code in models.py
>
> ''GinIndex(OpClass(Lower('historique'), name='gin_trgm_ops'),
> name="name_gin_trgm_histo_affaire")''
>
> It generates a migration operation :
>
> ''migrations.AddIndex(
>             model_name='affaire',
> index=django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.indexes.OpClass(django.db.models.functions.text.Lower('historique'),
> name='gin_trgm_ops'), name='name_gin_trgm_histo_affaire'),
>         ),
>
> ''
>
> The SQL generated instruction is :
>

> ''CREATE INDEX "name_gin_trgm_histo_affaire" ON "affaires_affaire" USING
> gin ((LOWER("historique") gin_trgm_ops));''
>
> It is refused by postgresql.
>
> The right code might be :
>
> CREATE INDEX "name_gin_trgm_histo_affaire" ON "affaires_affaire" USING
> gin (LOWER("historique") );
>
> that accepted by postgresql.
>
> Thanks,
>
> Regards,

New description:

 I have created a Gin Index using the folowing code in models.py
 {{{#!python
 GinIndex(OpClass(Lower('historique'), name='gin_trgm_ops'),
 name="name_gin_trgm_histo_affaire")
 }}}
 It generates a migration operation :

 {{{#!python
 migrations.AddIndex(
     model_name='affaire',
 
index=django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.indexes.OpClass(django.db.models.functions.text.Lower('historique'),
 name='gin_trgm_ops'), name='name_gin_trgm_histo_affaire'),
 )
 }}}

 The SQL generated instruction is :

 {{{#!sql
 CREATE INDEX "name_gin_trgm_histo_affaire" ON "affaires_affaire" USING gin
 ((LOWER("historique") gin_trgm_ops));
 }}}
 It is refused by postgresql.

 The right code might be :
 {{{#!sql
 CREATE INDEX "name_gin_trgm_histo_affaire" ON "affaires_affaire" USING gin
 (LOWER("historique") );
 }}}
 that accepted by postgresql.

--
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35262#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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018df76a4276-2d601dd2-cfdf-4bf9-9cfa-1187c0f46cce-000000%40eu-central-1.amazonses.com.

Reply via email to