Re: [Django] #35311: Addindex operation generates wrong sql code for Postgresql GinIndex

2024-03-16 Thread Django
#35311: Addindex operation generates wrong sql code for Postgresql GinIndex
-+-
 Reporter:  Pierre Juhen |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  duplicate
 Keywords:  postgresql   | Triage Stage:
  migration  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Tim Graham):

 * resolution:   => duplicate
 * status:  new => closed


Old description:

> Hi,
>
> I created a Gin Index using :
>
> ''GinIndex(OpClass(Lower('title'),  name='gin_trgm_ops'),
> name="name_gin_trgm_title_affaire"),''
>
> makemigrations generates the following code :
>
> ''migrations.AddIndex(
>'' model_name='affaire',
> index=django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.indexes.OpClass(django.db.models.functions.text.Lower('title'),
> name='gin_trgm_ops'), name='name_gin_trgm_title_affaire'),''
> ),''
>
> SQLMIGRATE generates a wrong code :
>
> ''CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING
> gin ((LOWER("title"), name=gin_trgm_ops));''
>
> Instead of (too many parenthesis) :
>
> ''CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING
> gin (LOWER("title"),  name=gin_trgm_ops);''
>
> There is a manual workaround, but its annoying.
>
> Thank you.
>
> Regards

New description:

 Hi,

 I created a Gin Index using :

 {{{
 GinIndex(OpClass(Lower('title'),  name='gin_trgm_ops'),
 name="name_gin_trgm_title_affaire"),'
 }}}

 makemigrations generates the following code :

 {{{
 migrations.AddIndex(
'' model_name='affaire',
 
index=django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.indexes.OpClass(django.db.models.functions.text.Lower('title'),
 name='gin_trgm_ops'), name='name_gin_trgm_title_affaire'),''
 ),''
 }}}
 SQLMIGRATE generates a wrong code :

 {{{
 CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING gin
 ((LOWER("title"), name=gin_trgm_ops));''
 }}}
 Instead of (too many parenthesis) :

 {{{
 CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING gin
 (LOWER("title"),  name=gin_trgm_ops);''
 }}}

 There is a manual workaround, but its annoying.

 Thank you.

 Regards

--
Comment:

 Duplicate of #33021. `django.contrib.postgres` must be in `INSTALLED_APPS`
 when using `OpClass()`. See
 [https://docs.djangoproject.com/en/stable/ref/contrib/postgres/indexes
 /#opclass-expressions docs] and related ticket #32770.
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018e46cf943e-a298c6e4-2233-4eef-b3cd-90d1b5b23d58-00%40eu-central-1.amazonses.com.


Re: [Django] #35311: Addindex operation generates wrong sql code for Postgresql GinIndex

2024-03-16 Thread Django
#35311: Addindex operation generates wrong sql code for Postgresql GinIndex
-+-
 Reporter:  Pierre Juhen |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  5.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  postgresql   | Triage Stage:
  migration  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by Pierre Juhen:

Old description:

> Hi,
>
> I created a Gin Index using :
>
> ''GinIndex(OpClass(Lower('title'),  name='gin_trgm_ops'),
> name="name_gin_trgm_title_affaire"),''
>
> makemigrations generates the following code :
>
> ''migrations.AddIndex(
>'' model_name='affaire',
> index=django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.indexes.OpClass(django.db.models.functions.text.Lower('title'),
> name='gin_trgm_ops'), name='name_gin_trgm_title_affaire'),''
> ),''
>
> SQLMIGRATE generates a wrong code :
>
> ''CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING
> gin ((LOWER("title")));''
>
> Instead of (too many parenthesis) :
>
> ''CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING
> gin (LOWER("title"));''
>
> There is a manual workaround, but its annoying.
>
> Thank you.
>
> Regards

New description:

 Hi,

 I created a Gin Index using :

 ''GinIndex(OpClass(Lower('title'),  name='gin_trgm_ops'),
 name="name_gin_trgm_title_affaire"),''

 makemigrations generates the following code :

 ''migrations.AddIndex(
'' model_name='affaire',
 
index=django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.indexes.OpClass(django.db.models.functions.text.Lower('title'),
 name='gin_trgm_ops'), name='name_gin_trgm_title_affaire'),''
 ),''

 SQLMIGRATE generates a wrong code :

 ''CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING
 gin ((LOWER("title"), name=gin_trgm_ops));''

 Instead of (too many parenthesis) :

 ''CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING
 gin (LOWER("title"),  name=gin_trgm_ops);''

 There is a manual workaround, but its annoying.

 Thank you.

 Regards

--
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018e466a4a2e-76dd1fcd-ef4e-4357-a7b7-34f0c4ab7c57-00%40eu-central-1.amazonses.com.


[Django] #35311: Addindex operation generates wrong sql code for Postgresql GinIndex

2024-03-16 Thread Django
#35311: Addindex operation generates wrong sql code for Postgresql GinIndex
-+-
   Reporter:  Pierre |  Owner:  nobody
  Juhen  |
   Type:  Bug| Status:  new
  Component:  Database   |Version:  5.0
  layer (models, ORM)|   Keywords:  postgresql
   Severity:  Normal |  migration
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 Hi,

 I created a Gin Index using :

 ''GinIndex(OpClass(Lower('title'),  name='gin_trgm_ops'),
 name="name_gin_trgm_title_affaire"),''

 makemigrations generates the following code :

 ''migrations.AddIndex(
'' model_name='affaire',
 
index=django.contrib.postgres.indexes.GinIndex(django.contrib.postgres.indexes.OpClass(django.db.models.functions.text.Lower('title'),
 name='gin_trgm_ops'), name='name_gin_trgm_title_affaire'),''
 ),''

 SQLMIGRATE generates a wrong code :

 ''CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING
 gin ((LOWER("title")));''

 Instead of (too many parenthesis) :

 ''CREATE INDEX "name_gin_trgm_title_affaire" ON "affaires_affaire" USING
 gin (LOWER("title"));''

 There is a manual workaround, but its annoying.

 Thank you.

 Regards
-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018e46648af5-3399de75-a558-4441-9da1-e8cf9d6707e8-00%40eu-central-1.amazonses.com.