mirror of
https://github.com/django/django.git
synced 2025-09-26 12:09:19 +00:00
Fixed #16055 -- Fixed crash when filtering against char/text GenericRelation relation on PostgreSQL.
This commit is contained in:
parent
594fcc2b74
commit
9bbf97bcdb
11 changed files with 117 additions and 13 deletions
|
@ -4,6 +4,7 @@ from django.core.management.color import no_style
|
|||
from django.db import NotSupportedError, connection, transaction
|
||||
from django.db.backends.base.operations import BaseDatabaseOperations
|
||||
from django.db.models import DurationField, Value
|
||||
from django.db.models.expressions import Col
|
||||
from django.test import (
|
||||
SimpleTestCase,
|
||||
TestCase,
|
||||
|
@ -159,6 +160,20 @@ class SimpleDatabaseOperationTests(SimpleTestCase):
|
|||
):
|
||||
self.ops.datetime_extract_sql(None, None, None, None)
|
||||
|
||||
def test_prepare_join_on_clause(self):
|
||||
author_table = Author._meta.db_table
|
||||
author_id_field = Author._meta.get_field("id")
|
||||
book_table = Book._meta.db_table
|
||||
book_fk_field = Book._meta.get_field("author")
|
||||
lhs_expr, rhs_expr = self.ops.prepare_join_on_clause(
|
||||
author_table,
|
||||
author_id_field,
|
||||
book_table,
|
||||
book_fk_field,
|
||||
)
|
||||
self.assertEqual(lhs_expr, Col(author_table, author_id_field))
|
||||
self.assertEqual(rhs_expr, Col(book_table, book_fk_field))
|
||||
|
||||
|
||||
class DatabaseOperationTests(TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue