mirror of
				https://github.com/django/django.git
				synced 2025-10-30 17:16:10 +00:00 
			
		
		
		
	This commit is contained in:
		| @@ -122,7 +122,7 @@ class Lookup(Expression): | ||||
|             # Ensure expression is wrapped in parentheses to respect operator | ||||
|             # precedence but avoid double wrapping as it can be misinterpreted | ||||
|             # on some backends (e.g. subqueries on SQLite). | ||||
|             if sql and sql[0] != "(": | ||||
|             if not isinstance(value, Value) and sql and sql[0] != "(": | ||||
|                 sql = "(%s)" % sql | ||||
|             return sql, params | ||||
|         else: | ||||
|   | ||||
| @@ -1366,6 +1366,12 @@ class LookupTests(TestCase): | ||||
|             [stock_1, stock_2], | ||||
|         ) | ||||
|  | ||||
|     def test_lookup_direct_value_rhs_unwrapped(self): | ||||
|         with self.assertNumQueries(1) as ctx: | ||||
|             self.assertIs(Author.objects.filter(GreaterThan(2, 1)).exists(), True) | ||||
|         # Direct values on RHS are not wrapped. | ||||
|         self.assertIn("2 > 1", ctx.captured_queries[0]["sql"]) | ||||
|  | ||||
|  | ||||
| class LookupQueryingTests(TestCase): | ||||
|     @classmethod | ||||
|   | ||||
		Reference in New Issue
	
	Block a user