trust

Finished
139139 return "".join(path)
140140
141141
142def compile_json_path_for_keys(key_transforms, include_root=True):
143 """
144 Compile JSON path treating all keys as string keys, not array indices.
145 This is used for has_key lookups where numeric string keys like "1111"
146 should be treated as object keys, not array indices.
147 """
148 path = ["$"] if include_root else []
149 for key_transform in key_transforms:
150 # Always treat keys as string keys, not array indices
151 path.append(".")
152 path.append(json.dumps(key_transform))
153 return "".join(path)
154
155
142156class DataContains(PostgresOperatorLookup):
143157 lookup_name = "contains"
144158 postgres_operator = "@>"
197211 "%s%s"
198212 % (
199213 lhs_json_path,
200 compile_json_path(rhs_key_transforms, include_root=False),
214 compile_json_path_for_keys(rhs_key_transforms, include_root=False),
201215 )
202216 )
203217 # Add condition for each key.
Test NameStatus
test_has_key_deep (model_fields.test_jsonfield.TestQuerying)
Fail
test_has_key_list (model_fields.test_jsonfield.TestQuerying)
Fail
test_has_key_null_value (model_fields.test_jsonfield.TestQuerying)
Fail
test_key_transform_annotation_expression (model_fields.test_jsonfield.TestQuerying)
Fail
test_key_transform_expression (model_fields.test_jsonfield.TestQuerying)
Fail
test_nested_key_transform_annotation_expression (model_fields.test_jsonfield.TestQuerying)
Fail
test_nested_key_transform_expression (model_fields.test_jsonfield.TestQuerying)
Fail
test_nested_key_transform_on_subquery (model_fields.test_jsonfield.TestQuerying)
Fail
test_ordering_grouping_by_key_transform (model_fields.test_jsonfield.TestQuerying)
Fail
test_has_key_number (model_fields.test_jsonfield.TestQuerying)
Pass
test_has_keys (model_fields.test_jsonfield.TestQuerying)
Pass
test_formfield (model_fields.test_jsonfield.TestFormField)
Pass
test_formfield_custom_encoder_decoder (model_fields.test_jsonfield.TestFormField)
Pass
test_custom_encoder (model_fields.test_jsonfield.TestValidation)
Pass
test_invalid_decoder (model_fields.test_jsonfield.TestValidation)
Pass
test_invalid_encoder (model_fields.test_jsonfield.TestValidation)
Pass
test_validation_error (model_fields.test_jsonfield.TestValidation)
Pass
test_custom_encoder_decoder (model_fields.test_jsonfield.JSONFieldTests)
Pass
test_db_check_constraints (model_fields.test_jsonfield.JSONFieldTests)
Pass
test_invalid_value (model_fields.test_jsonfield.JSONFieldTests)
Pass
test_deconstruct (model_fields.test_jsonfield.TestMethods)
Pass
test_deconstruct_custom_encoder_decoder (model_fields.test_jsonfield.TestMethods)
Pass
test_get_transforms (model_fields.test_jsonfield.TestMethods)
Pass
test_key_transform_text_lookup_mixin_non_key_transform (model_fields.test_jsonfield.TestMethods)
Pass
test_dict (model_fields.test_jsonfield.TestSaveLoad)
Pass
test_json_null_different_from_sql_null (model_fields.test_jsonfield.TestSaveLoad)
Pass
test_list (model_fields.test_jsonfield.TestSaveLoad)
Pass
test_null (model_fields.test_jsonfield.TestSaveLoad)
Pass
test_primitives (model_fields.test_jsonfield.TestSaveLoad)
Pass
test_realistic_object (model_fields.test_jsonfield.TestSaveLoad)
Pass
test_dumping (model_fields.test_jsonfield.TestSerialization)
Pass
test_loading (model_fields.test_jsonfield.TestSerialization)
Pass
test_xml_serialization (model_fields.test_jsonfield.TestSerialization)
Pass
test_contained_by_unsupported (model_fields.test_jsonfield.TestQuerying)
Pass
test_contains_unsupported (model_fields.test_jsonfield.TestQuerying)
Pass
test_deep_lookup_array (model_fields.test_jsonfield.TestQuerying)
Pass
test_deep_lookup_mixed (model_fields.test_jsonfield.TestQuerying)
Pass
test_deep_lookup_objs (model_fields.test_jsonfield.TestQuerying)
Pass
test_deep_lookup_transform (model_fields.test_jsonfield.TestQuerying)
Pass
test_deep_values (model_fields.test_jsonfield.TestQuerying)
Pass
test_exact (model_fields.test_jsonfield.TestQuerying)
Pass
test_exact_complex (model_fields.test_jsonfield.TestQuerying)
Pass
test_expression_wrapper_key_transform (model_fields.test_jsonfield.TestQuerying)
Pass
test_has_any_keys (model_fields.test_jsonfield.TestQuerying)
Pass
test_has_key (model_fields.test_jsonfield.TestQuerying)
Pass
test_icontains (model_fields.test_jsonfield.TestQuerying)
Pass
test_isnull (model_fields.test_jsonfield.TestQuerying)
Pass
test_isnull_key (model_fields.test_jsonfield.TestQuerying)
Pass
test_isnull_key_or_none (model_fields.test_jsonfield.TestQuerying)
Pass
test_join_key_transform_annotation_expression (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_endswith (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_escape (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_icontains (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_iendswith (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_iexact (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_in (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_iregex (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_istartswith (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_quoted_string (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_regex (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_sql_injection_escape (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_startswith (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_transform_raw_expression (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_values (model_fields.test_jsonfield.TestQuerying)
Pass
test_key_values_boolean (model_fields.test_jsonfield.TestQuerying)
Pass
test_lookup_exclude (model_fields.test_jsonfield.TestQuerying)
Pass
test_lookup_exclude_nonexistent_key (model_fields.test_jsonfield.TestQuerying)
Pass
test_lookups_with_key_transform (model_fields.test_jsonfield.TestQuerying)
Pass
test_nested_key_transform_raw_expression (model_fields.test_jsonfield.TestQuerying)
Pass
test_none_key (model_fields.test_jsonfield.TestQuerying)
Pass
test_none_key_and_exact_lookup (model_fields.test_jsonfield.TestQuerying)
Pass
test_none_key_exclude (model_fields.test_jsonfield.TestQuerying)
Pass
test_obj_subquery_lookup (model_fields.test_jsonfield.TestQuerying)
Pass
test_order_grouping_custom_decoder (model_fields.test_jsonfield.TestQuerying)
Pass
test_ordering_by_transform (model_fields.test_jsonfield.TestQuerying)
Pass
test_ordering_grouping_by_count (model_fields.test_jsonfield.TestQuerying)
Pass
test_shallow_list_lookup (model_fields.test_jsonfield.TestQuerying)
Pass
test_shallow_lookup_obj_target (model_fields.test_jsonfield.TestQuerying)
Pass
test_shallow_obj_lookup (model_fields.test_jsonfield.TestQuerying)
Pass
test_usage_in_subquery (model_fields.test_jsonfield.TestQuerying)
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.