Boom

Finished
129129def compile_json_path(key_transforms, include_root=True):
130130 path = ["$"] if include_root else []
131131 for key_transform in key_transforms:
132 try:
133 num = int(key_transform)
134 except ValueError: # non-integer
132 # If it's already a string, treat it as a JSON object key
133 if isinstance(key_transform, str):
135134 path.append(".")
136135 path.append(json.dumps(key_transform))
136 # If it's a boolean, treat it as an array index (True=1, False=0)
137 # Note: This check must come before int check since bool is a subclass of int
138 elif isinstance(key_transform, bool):
139 path.append("[%s]" % int(key_transform))
140 # If it's an integer, treat it as an array index
141 elif isinstance(key_transform, int):
142 path.append("[%s]" % key_transform)
143 # If it's None, treat it as a string key "null"
144 elif key_transform is None:
145 path.append(".")
146 path.append(json.dumps("null"))
147 # For any other type, try to convert to int for array index, otherwise treat as string
137148 else:
138 path.append("[%s]" % num)
149 try:
150 num = int(key_transform)
151 path.append("[%s]" % num)
152 except (ValueError, TypeError): # non-integer or non-convertible
153 path.append(".")
154 path.append(json.dumps(str(key_transform)))
139155 return "".join(path)
140156
141157
Test NameStatus
test_has_key_number (model_fields.test_jsonfield.TestQuerying)
Fail
test_has_keys (model_fields.test_jsonfield.TestQuerying)
Fail
test_deep_lookup_array (model_fields.test_jsonfield.TestQuerying)
Fail
test_deep_lookup_mixed (model_fields.test_jsonfield.TestQuerying)
Fail
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_join_key_transform_annotation_expression (model_fields.test_jsonfield.TestQuerying)
Fail
test_key_in (model_fields.test_jsonfield.TestQuerying)
Fail
test_key_iregex (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_count (model_fields.test_jsonfield.TestQuerying)
Fail
test_ordering_grouping_by_key_transform (model_fields.test_jsonfield.TestQuerying)
Fail
test_shallow_list_lookup (model_fields.test_jsonfield.TestQuerying)
Fail
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_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_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_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_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.