Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-04-18 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  closed
Component:   |  Version:  3.2
  contrib.contenttypes   |
 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 Mariusz Felisiak ):

 In [changeset:"8b1ff0da4b162e87edebd94e61f2cd153e9e159d" 8b1ff0da]:
 {{{
 #!CommitTicketReference repository=""
 revision="8b1ff0da4b162e87edebd94e61f2cd153e9e159d"
 Refs #16055 -- Deprecated
 get_joining_columns()/get_reverse_joining_columns() methods.
 }}}

-- 
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/0107018794a26dba-33019ee4-bfa5-41a7-b5a6-a3b66e9aa74a-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-04-18 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  closed
Component:   |  Version:  3.2
  contrib.contenttypes   |
 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 Mariusz Felisiak ):

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


Comment:

 In [changeset:"9bbf97bcdb488bb11aebb5bd405549fbec6852cd" 9bbf97bc]:
 {{{
 #!CommitTicketReference repository=""
 revision="9bbf97bcdb488bb11aebb5bd405549fbec6852cd"
 Fixed #16055 -- Fixed crash when filtering against char/text
 GenericRelation relation on PostgreSQL.
 }}}

-- 
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/0107018794a26d86-29c47a75-ae7f-436f-9c49-f56451301ad7-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-04-18 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 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 Mariusz Felisiak):

 * stage:  Accepted => Ready for checkin


-- 
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/0107018794037b5a-37f28880-3c52-4c85-8a7d-f691232fd198-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-04-18 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 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 David Wobrock):

 * needs_better_patch:  1 => 0
 * needs_tests:  1 => 0


-- 
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/0107018793257314-663804dd-e171-4bf2-9913-c24d669dd0f1-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-04-11 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1
 * needs_tests:  0 => 1


-- 
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/010701876f483e84-0b398ffc-3877-4fbe-9d8f-be0ea5e4fb8a-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-04-10 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 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 David Wobrock):

 * needs_better_patch:  1 => 0
 * needs_tests:  1 => 0


-- 
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/010701876ae69c78-630f56c9-fa46-4fc0-949f-a88fa2d6c6c5-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-03-14 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  1|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1
 * needs_tests:  0 => 1


-- 
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/01070186df0b3487-60545d5c-2b99-41ed-9a28-b4643f1a2f34-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-03-11 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 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 David Wobrock):

 * needs_better_patch:  1 => 0


-- 
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/01070186d1f149ec-4c5522b6-2cf6-46a0-994e-cdd0055d6b5c-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-03-10 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1


-- 
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/01070186cb658072-61c76516-b36c-4a24-bb10-20b15903506c-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-03-08 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 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 David Wobrock):

 * needs_better_patch:  1 => 0


-- 
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/01070186c21754d7-5d0323cd-5d54-40a4-beeb-35e73bd5102c-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-03-07 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  1
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Mariusz Felisiak):

 * needs_better_patch:  0 => 1


Comment:

 Per Simon's comments.

-- 
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/01070186c03a1331-f95d64b2-12ae-49b2-8b82-e60540d9e5cb-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2023-03-07 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
-+-
 Reporter:  anonymous|Owner:  David
 |  Wobrock
 Type:  Bug  |   Status:  assigned
Component:   |  Version:  3.2
  contrib.contenttypes   |
 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 David Wobrock):

 * cc: David Wobrock (added)
 * owner:  nobody => David Wobrock
 * has_patch:  0 => 1
 * status:  new => assigned


Comment:

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

-- 
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/01070186bc30a0c6-8f60cde1-ecab-4e48-87f9-3e8f42d29d3b-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2022-12-21 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  3.2
 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 Sage Abdullah):

 * cc: Sage Abdullah (added)


-- 
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/0107018535ddf612-ad7b5c73-26ea-4ec1-aae3-bcf8182e99a8-00%40eu-central-1.amazonses.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2021-04-21 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  3.2
 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 Marc DEBUREAUX):

 * cc: Marc DEBUREAUX (added)
 * version:  1.3 => 3.2


Comment:

 Change Django version number for visibility purposes.

-- 
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/067.c7df49df297bd6caa5a66d7920ee2485%40djangoproject.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2021-04-21 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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
--+

Comment (by Marc DEBUREAUX):

 Manage to create something based on Simon Charette's suggestion.

 Creating a custom `GenericRelation` with the following:
 - `get_joining_columns` returning an empty tuple
 - `get_extra_restriction` building the whole where clause with content
 type **AND** primary key join with Cast

 Here's the result:

 {{{#!python
 class CustomGenericRelation(GenericRelation):
 def get_joining_columns(self, reverse_join=False):
 joining_columns = super().get_joining_columns(reverse_join)
 self.joining_columns = joining_columns
 return tuple()

 def get_extra_restriction(self, where_class, alias, remote_alias):
 cond = super().get_extra_restriction(where_class, alias,
 remote_alias)
 from_field = self.model._meta.pk
 to_field =
 self.remote_field.model._meta.get_field(self.object_id_field_name)
 lookup = from_field.get_lookup('exact')(
 Cast(from_field.get_col(alias),
 output_field=models.TextField()),
 to_field.get_col(remote_alias))
 cond.add(lookup, 'AND')
 return cond
 }}}

 Giving the following:
 - a model `common.History` having a `GenericForeignKey` with `object_id`
 as text
 - a model `generic.Twitter` having a `CustomGenericRelation` and a numeric
 primary key
 - and the queryset:

 {{{#!python
 q =
 Twitter.objects.values('id').filter(id=1).annotate(count=Count('histories'))
 print(q.query)
 }}}

 It gives the following SQL query:

 {{{#!sql
 SELECT
 "generic_twitter"."id",
 COUNT("common_history"."id") AS "count"
 FROM "generic_twitter"
 LEFT OUTER JOIN "common_history" ON
 (((
 "common_history"."content_type_id" = 29 AND
 CAST("generic_twitter"."id" AS text) = "common_history"."object_id"
 )))
 WHERE "generic_twitter"."id" = 1
 GROUP BY "generic_twitter"."id"
 }}}

 Instead of this one (normal behaviour):

 {{{#!sql
 SELECT
 "generic_twitter"."id",
 COUNT("common_history"."id") AS "count"
 FROM "generic_twitter"
 LEFT OUTER JOIN "common_history" ON
 (
 "generic_twitter"."id" = "common_history"."object_id" AND
 ("common_history"."content_type_id" = 29)
 )
 WHERE "generic_twitter"."id" = 1
 GROUP BY "generic_twitter"."id"
 }}}

-- 
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/067.95fe18f78f202c9d194c84ef5359e563%40djangoproject.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2021-02-24 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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
--+

Comment (by Simon Charette):

 Note that another elegant solution to this problem could be to add support
 to transforms to `ForeignObject.to_fields` and `.from_fields` so you could
 do something along these lines

 {{{#!python
 class Animal(models.Model):
 name = models.TextField()
 tags = generic.GenericRelation(Tag, from_field='id__text')
 }}}

 (assuming we'd register a `__text` lookup for `IntegerField`)

-- 
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/067.3383956da56fba37eaa952930decdec8%40djangoproject.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2020-02-18 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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
--+

Comment (by Nekmo):

 I have made a hack for Django-guardian. In my case, this query is the one
 that fails:


 {{{
 from customers.models import CustomerMemberObjectPermission

 
CustomerMemberObjectPermission.objects.filter(service_api__service__service_name='foo')
 # Raise DatabaseError
 }}}

 My models:

 {{{
 class CustomerMemberObjectPermission(UserObjectPermission):
 objects = CustomerMemberObjectPermissionManager()


 class ServiceApi(Model):
 customer_permissions = GenericRelation(CustomerMemberObjectPermission,
 object_id_field='object_pk',
 related_query_name='service_api')
 }}}

 This is the wrong sql:
 {{{
 SELECT "guardian_userobjectpermission"."id",
 "guardian_userobjectpermission"."permission_id",
 "guardian_userobjectpermission"."content_type_id",
 "guardian_userobjectpermission"."object_pk",
 "guardian_userobjectpermission"."user_id" FROM
 "guardian_userobjectpermission" INNER JOIN "services_serviceapi" ON
 ("guardian_userobjectpermission"."object_pk" = "services_serviceapi"."id"
 AND ("guardian_userobjectpermission"."content_type_id" = 22)) INNER JOIN
 "services_service" ON ("services_serviceapi"."service_id" =
 "services_service"."id") INNER JOIN "customers_customer" ON
 ("services_service"."customer_id" = "customers_customer"."id") WHERE
 "customers_customer"."customer_code" = BCL
 }}}

 The error is in the inner join. Django-guardian uses a field of type
 string for object_pk. But my id is a integer type:
 {{{
 "guardian_userobjectpermission"."object_pk" = "services_serviceapi"."id"
 }}}

 The solution is to use a cast:
 {{{
 CAST("guardian_userobjectpermission"."object_pk" AS integer) =
 "services_serviceapi"."id"
 }}}

 Although I know it is not the best, my solution has been this hack thanks
 to Simon Charette:
 {{{
 class CustomJoin(Join):
 def as_sql(self, compiler, connection):
 sql, params = super(CustomJoin, self).as_sql(compiler, connection)
 sql = sql.replace('"guardian_userobjectpermission"."object_pk"',
 'CAST("guardian_userobjectpermission"."object_pk" AS integer)')
 return sql, params


 class CustomSQLCompiler(SQLCompiler):
 def compile(self, node, select_format=False):
 if isinstance(node, Join):
 node = CustomJoin(
 node.table_name, node.parent_alias, node.table_alias,
 node.join_type,
 node.join_field, node.nullable, node.filtered_relation
 )
 return super(CustomSQLCompiler, self).compile(node, select_format)


 class CustomQuery(Query):
 def get_compiler(self, using=None, connection=None):
 original_compiler = super(CustomQuery,
 self).get_compiler(using=using, connection=connection)
 return CustomSQLCompiler(original_compiler.query,
 original_compiler.connection, original_compiler.using)
 # return super(CustomQuery, self).get_compiler(using=using,
 connection=connection)


 class CustomerMemberObjectPermissionQuerySet(CustomerQuerySet):
 def __init__(self, model=None, query=None, using=None, hints=None):
 if not query:
 query = CustomQuery(model)
 super(CustomerMemberObjectPermissionQuerySet, self).__init__(
 model=model, query=query, using=using, hints=hints
 )


 class CustomerMemberObjectPermissionManager(CustomerManager,
 UserObjectPermissionManager):
 def get_queryset(self):
 return CustomerMemberObjectPermissionQuerySet(self.model,
 using=self._db)
 }}}

-- 
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/067.40cc091896a93c381ca26cf22c8a759b%40djangoproject.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2019-12-17 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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
--+

Comment (by Simon Charette):

 If anyone is interested in addressing this issue it should be doable by
 adjusting `Join.as_sql` to add the appropriate cast when `lhs_col` and
 `rhs_col`'s `.db_type(connection)` doesn't match.


 
https://github.com/django/django/blob/129583a0d3cf69b08d058cd751d777588801b7ad/django/db/models/sql/datastructures.py#L70-L77

 Ideally most of the `Cast` logic would be moved to the database backend
 operations so `Join.as_sql` can rely on it instead of having to depend on
 `db.models` stuff.

 A less invasive solution would be to make `GenericRelation`'s `join_field`
 return an empty `get_joining_columns` and include the adapted condition in
 `get_extra_restriction` instead but that seems like this should be solved
 at the `Join` level instead since we don't offer a low level way of
 completely configuring join conditions; we only allow to augment them
 using `FilteredRelation`.

-- 
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/067.b976177ce18117d6d3b630738f033b04%40djangoproject.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2019-12-17 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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 Kevin Wiliarty):

 * cc: Kevin Wiliarty (added)


-- 
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/067.d6c7daf3ff740fcc49a17047c74d4fda%40djangoproject.com.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2018-04-11 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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 Kye Russell):

 * cc: Kye Russell (added)


-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.915c6bebc5d4d0b7b3aebdd640974f7e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2016-01-06 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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 brian):

 * cc: brian@… (added)


--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.3c9a8dc28b4e6ab7e32504ac6bf34706%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2016-01-06 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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 mitar):

 * cc: mmitar@… (added)


--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.999de66c80a564292249873483ee53c8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2015-10-02 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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
--+

Comment (by timgraham):

 #20271 is a duplicate with an alternate test.

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.a5943dce839d495ffcdac3bcc14f9655%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres

2015-10-02 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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 timgraham):

 * Attachment "16055-test.diff" added.


--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.e24b21be74dce6e253f3a46298edf88c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #16055: Filtering over generic relations with TextField/CharField object_id breaks in postgres (was: Filtering over funky generic relations breaks in postgres)

2015-10-02 Thread Django
#16055: Filtering over generic relations with TextField/CharField object_id 
breaks
in postgres
--+
 Reporter:  anonymous |Owner:  nobody
 Type:  Bug   |   Status:  new
Component:  contrib.contenttypes  |  Version:  1.3
 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 timgraham):

 * component:  Database layer (models, ORM) => contrib.contenttypes


Comment:

 I updated the tests to apply cleanly to master and verified the failure on
 PostgreSQL 9.4 at 58c7ff39fb265754fb17ab8d7f8a1401b355777b (Django
 1.10.dev).
 {{{
 ==
 ERROR: test_charlink_filter
 (generic_relations_regress.tests.GenericRelationTests)
 --
 Traceback (most recent call last):
   File "/home/tim/code/django/tests/generic_relations_regress/tests.py",
 line 57, in test_charlink_filter
 list(OddRelation1.objects.filter(clinks__title='title'))
   File "/home/tim/code/django/django/db/models/query.py", line 258, in
 __iter__
 self._fetch_all()
   File "/home/tim/code/django/django/db/models/query.py", line 1074, in
 _fetch_all
 self._result_cache = list(self.iterator())
   File "/home/tim/code/django/django/db/models/query.py", line 52, in
 __iter__
 results = compiler.execute_sql()
   File "/home/tim/code/django/django/db/models/sql/compiler.py", line 839,
 in execute_sql
 cursor.execute(sql, params)
   File "/home/tim/code/django/django/db/backends/utils.py", line 64, in
 execute
 return self.cursor.execute(sql, params)
   File "/home/tim/code/django/django/db/utils.py", line 92, in __exit__
 six.reraise(dj_exc_type, dj_exc_value, traceback)
   File "/home/tim/code/django/django/db/backends/utils.py", line 64, in
 execute
 return self.cursor.execute(sql, params)
 ProgrammingError: operator does not exist: integer = character varying
 LINE 1: ...ON ("generic_relations_regress_oddrelation1"."id" = "generic...
  ^
 HINT:  No operator matches the given name and argument type(s). You might
 need to add explicit type casts.
 }}}

--
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.7f556cda77a77df1a79e64b2a60bbf8c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.