hare-orm 0.9.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hare/__init__.py +47 -0
- hare/__main__.py +8 -0
- hare/classes/__init__.py +1 -0
- hare/classes/class_path.py +50 -0
- hare/classes/class_property.py +18 -0
- hare/classes/comparable_values.py +113 -0
- hare/classes/constants.py +11 -0
- hare/classes/declared_subclass.py +26 -0
- hare/classes/lazy_exports.py +56 -0
- hare/classes/shown_value_repr.py +21 -0
- hare/classes/value_descriptions.py +81 -0
- hare/cli/__init__.py +3 -0
- hare/cli/__main__.py +7 -0
- hare/cli/arg_parser_builder.py +344 -0
- hare/cli/commands/__init__.py +0 -0
- hare/cli/commands/database_shell_commands.py +56 -0
- hare/cli/commands/distributed_recovery_commands.py +86 -0
- hare/cli/commands/interactive_rename_questions.py +30 -0
- hare/cli/commands/migration_commands.py +579 -0
- hare/cli/commands/schema_commands.py +123 -0
- hare/cli/commands/stub_commands.py +52 -0
- hare/cli/config_locator.py +37 -0
- hare/cli/constants.py +24 -0
- hare/cli/context/__init__.py +9 -0
- hare/cli/context/cli_context.py +17 -0
- hare/cli/context/command_context.py +108 -0
- hare/cli/exceptions.py +9 -0
- hare/cli/hare_cli.py +111 -0
- hare/cli/output/__init__.py +1 -0
- hare/cli/output/output_formatter.py +145 -0
- hare/cli/output/terminal_colors.py +89 -0
- hare/cli/plugins/__init__.py +16 -0
- hare/cli/plugins/cli_command.py +43 -0
- hare/cli/plugins/cli_command_registry.py +144 -0
- hare/cli/plugins/loaded_cli_command.py +13 -0
- hare/cli/shell_launcher.py +95 -0
- hare/contrib/__init__.py +0 -0
- hare/contrib/application_lifecycle.py +157 -0
- hare/contrib/factories/__init__.py +39 -0
- hare/contrib/factories/constants.py +21 -0
- hare/contrib/factories/factory_reference.py +27 -0
- hare/contrib/factories/field_declarations/__init__.py +1 -0
- hare/contrib/factories/field_declarations/declaration.py +19 -0
- hare/contrib/factories/field_declarations/faker.py +49 -0
- hare/contrib/factories/field_declarations/iterator.py +36 -0
- hare/contrib/factories/field_declarations/lazy_attribute.py +35 -0
- hare/contrib/factories/field_declarations/lazy_function.py +22 -0
- hare/contrib/factories/field_declarations/many_to_many.py +40 -0
- hare/contrib/factories/field_declarations/post_declaration.py +22 -0
- hare/contrib/factories/field_declarations/related_factory.py +37 -0
- hare/contrib/factories/field_declarations/sequence.py +22 -0
- hare/contrib/factories/field_declarations/sub_factory.py +30 -0
- hare/contrib/factories/model_factory.py +284 -0
- hare/contrib/factories/trait.py +23 -0
- hare/contrib/frameworks/__init__.py +14 -0
- hare/contrib/frameworks/constants.py +45 -0
- hare/contrib/frameworks/error_answers.py +93 -0
- hare/contrib/frameworks/exceptions.py +19 -0
- hare/contrib/frameworks/fastapi/__init__.py +12 -0
- hare/contrib/frameworks/fastapi/constants.py +4 -0
- hare/contrib/frameworks/fastapi/hare_exception_handlers.py +103 -0
- hare/contrib/frameworks/fastapi/hare_fast_api.py +139 -0
- hare/contrib/frameworks/fastapi/middleware/__init__.py +7 -0
- hare/contrib/frameworks/fastapi/middleware/request_state_reset_middleware.py +27 -0
- hare/contrib/frameworks/fastapi/middleware/transaction_failing_handler.py +31 -0
- hare/contrib/frameworks/fastapi/middleware/transaction_middleware.py +72 -0
- hare/contrib/frameworks/fastapi/request_query_dependency.py +88 -0
- hare/contrib/frameworks/hare_lifecycle.py +50 -0
- hare/contrib/frameworks/health_routes.py +101 -0
- hare/contrib/frameworks/litestar/__init__.py +14 -0
- hare/contrib/frameworks/litestar/constants.py +18 -0
- hare/contrib/frameworks/litestar/hare_dto.py +194 -0
- hare/contrib/frameworks/litestar/hare_exception_handlers.py +77 -0
- hare/contrib/frameworks/litestar/hare_plugin.py +181 -0
- hare/contrib/frameworks/litestar/hare_transfer_function_factory.py +38 -0
- hare/contrib/frameworks/litestar/middleware/__init__.py +7 -0
- hare/contrib/frameworks/litestar/middleware/request_state_reset_middleware.py +23 -0
- hare/contrib/frameworks/litestar/middleware/transaction_middleware.py +35 -0
- hare/contrib/frameworks/litestar/request_query_di_plugin.py +96 -0
- hare/contrib/frameworks/pages/__init__.py +22 -0
- hare/contrib/frameworks/pages/cursor_page_schema.py +25 -0
- hare/contrib/frameworks/pages/page_schema.py +25 -0
- hare/contrib/frameworks/pages/scroll_page_schema.py +23 -0
- hare/contrib/frameworks/parameter_annotation.py +110 -0
- hare/contrib/frameworks/request_state.py +16 -0
- hare/contrib/frameworks/request_transaction.py +186 -0
- hare/contrib/frameworks/robyn/__init__.py +13 -0
- hare/contrib/frameworks/robyn/application/__init__.py +11 -0
- hare/contrib/frameworks/robyn/application/hare_robyn.py +199 -0
- hare/contrib/frameworks/robyn/application/hare_sub_router.py +50 -0
- hare/contrib/frameworks/robyn/constants.py +32 -0
- hare/contrib/frameworks/robyn/hare_exception_handlers.py +128 -0
- hare/contrib/frameworks/robyn/hare_open_api.py +91 -0
- hare/contrib/frameworks/robyn/route_handler.py +198 -0
- hare/contrib/mypy/__init__.py +11 -0
- hare/contrib/mypy/annotation_types.py +170 -0
- hare/contrib/mypy/constants.py +83 -0
- hare/contrib/mypy/enums.py +18 -0
- hare/contrib/mypy/field_names_check.py +222 -0
- hare/contrib/mypy/filter_arguments_check.py +129 -0
- hare/contrib/mypy/hare_mypy_plugin.py +166 -0
- hare/contrib/mypy/instance_attribute_types.py +137 -0
- hare/contrib/mypy/model_registry.py +127 -0
- hare/contrib/mypy/mypy_types.py +383 -0
- hare/contrib/mypy/queryset_extension_methods.py +109 -0
- hare/contrib/mypy/values_row_types.py +146 -0
- hare/contrib/mypy/write_arguments_check.py +159 -0
- hare/contrib/notify/__init__.py +5 -0
- hare/contrib/notify/constants.py +14 -0
- hare/contrib/notify/notification_listener.py +317 -0
- hare/contrib/opentelemetry/__init__.py +16 -0
- hare/contrib/opentelemetry/constants.py +31 -0
- hare/contrib/opentelemetry/open_telemetry_instrumentor.py +60 -0
- hare/contrib/opentelemetry/pool_metric_instruments.py +210 -0
- hare/contrib/opentelemetry/query_spans.py +69 -0
- hare/contrib/outbox/__init__.py +65 -0
- hare/contrib/outbox/broker_arguments.py +40 -0
- hare/contrib/outbox/brokers/__init__.py +1 -0
- hare/contrib/outbox/brokers/rabbitmq_connection.py +55 -0
- hare/contrib/outbox/brokers/redis_connection.py +42 -0
- hare/contrib/outbox/capture/__init__.py +6 -0
- hare/contrib/outbox/capture/change_capture.py +366 -0
- hare/contrib/outbox/capture/change_extension.py +22 -0
- hare/contrib/outbox/capture/constants.py +19 -0
- hare/contrib/outbox/constants.py +31 -0
- hare/contrib/outbox/deliveries/__init__.py +22 -0
- hare/contrib/outbox/deliveries/callable_delivery.py +44 -0
- hare/contrib/outbox/deliveries/constants.py +19 -0
- hare/contrib/outbox/deliveries/kafka_delivery.py +124 -0
- hare/contrib/outbox/deliveries/outbox_delivery.py +106 -0
- hare/contrib/outbox/deliveries/rabbitmq_delivery.py +63 -0
- hare/contrib/outbox/deliveries/redis_streams_delivery.py +110 -0
- hare/contrib/outbox/deliveries/topic_router.py +103 -0
- hare/contrib/outbox/deliveries/webhook_delivery.py +106 -0
- hare/contrib/outbox/exceptions.py +7 -0
- hare/contrib/outbox/outbox_event.py +362 -0
- hare/contrib/outbox/outbox_json_encoding.py +87 -0
- hare/contrib/outbox/relay/__init__.py +7 -0
- hare/contrib/outbox/relay/constants.py +41 -0
- hare/contrib/outbox/relay/declarations.py +76 -0
- hare/contrib/outbox/relay/outbox_backlog.py +18 -0
- hare/contrib/outbox/relay/outbox_relay.py +646 -0
- hare/contrib/outbox/wakeups/__init__.py +20 -0
- hare/contrib/outbox/wakeups/constants.py +20 -0
- hare/contrib/outbox/wakeups/in_process_wakeup.py +17 -0
- hare/contrib/outbox/wakeups/kafka_wakeup.py +123 -0
- hare/contrib/outbox/wakeups/listen_notify_wakeup.py +75 -0
- hare/contrib/outbox/wakeups/outbox_wakeup.py +202 -0
- hare/contrib/outbox/wakeups/rabbitmq_wakeup.py +64 -0
- hare/contrib/outbox/wakeups/redis_wakeup.py +53 -0
- hare/contrib/pydantic/__init__.py +12 -0
- hare/contrib/pydantic/constants.py +41 -0
- hare/contrib/pydantic/creation/__init__.py +1 -0
- hare/contrib/pydantic/creation/computed_field_schemas.py +77 -0
- hare/contrib/pydantic/creation/data_field_schemas.py +230 -0
- hare/contrib/pydantic/creation/field_descriptions.py +17 -0
- hare/contrib/pydantic/creation/field_map.py +138 -0
- hare/contrib/pydantic/creation/generic_foreign_key_schemas.py +136 -0
- hare/contrib/pydantic/creation/generic_foreign_key_tag_reader.py +35 -0
- hare/contrib/pydantic/creation/model_annotations.py +44 -0
- hare/contrib/pydantic/creation/pydantic_creators.py +163 -0
- hare/contrib/pydantic/creation/pydantic_meta_reading.py +134 -0
- hare/contrib/pydantic/creation/pydantic_model_creator.py +434 -0
- hare/contrib/pydantic/creation/relation_field_schemas.py +269 -0
- hare/contrib/pydantic/descriptions/__init__.py +5 -0
- hare/contrib/pydantic/descriptions/computed_field_description.py +12 -0
- hare/contrib/pydantic/descriptions/model_description.py +69 -0
- hare/contrib/pydantic/descriptions/pydantic_meta_data.py +144 -0
- hare/contrib/pydantic/enums.py +12 -0
- hare/contrib/pydantic/models/__init__.py +9 -0
- hare/contrib/pydantic/models/pydantic_list_model.py +34 -0
- hare/contrib/pydantic/models/pydantic_model.py +292 -0
- hare/contrib/pytest/__init__.py +17 -0
- hare/contrib/pytest/constants.py +26 -0
- hare/contrib/pytest/hare_fixtures.py +112 -0
- hare/contrib/pytest/missing_pytest_asyncio_fixtures.py +34 -0
- hare/contrib/pytest/plugin.py +49 -0
- hare/contrib/repeated_queries/__init__.py +19 -0
- hare/contrib/repeated_queries/constants.py +10 -0
- hare/contrib/repeated_queries/repeated_query_collection.py +116 -0
- hare/contrib/repeated_queries/repeated_query_detector.py +227 -0
- hare/contrib/repeated_queries/repeated_query_entry.py +20 -0
- hare/contrib/repeated_queries/repeated_query_report.py +31 -0
- hare/contrib/repeated_queries/shape_stats.py +18 -0
- hare/contrib/request_query/__init__.py +71 -0
- hare/contrib/request_query/bounds/__init__.py +6 -0
- hare/contrib/request_query/bounds/constants.py +4 -0
- hare/contrib/request_query/bounds/lookup_pair_bounds.py +40 -0
- hare/contrib/request_query/bounds/parameter_bounds.py +41 -0
- hare/contrib/request_query/bounds/range_bounds.py +30 -0
- hare/contrib/request_query/constants.py +45 -0
- hare/contrib/request_query/declaration/__init__.py +6 -0
- hare/contrib/request_query/declaration/constants.py +19 -0
- hare/contrib/request_query/declaration/declaration_builder.py +515 -0
- hare/contrib/request_query/declaration/filter_declaration.py +25 -0
- hare/contrib/request_query/declaration/filter_parameter_builder.py +201 -0
- hare/contrib/request_query/declaration/parameter_filter.py +17 -0
- hare/contrib/request_query/declaration/request_query_declaration.py +138 -0
- hare/contrib/request_query/declaration/request_query_parameters.py +54 -0
- hare/contrib/request_query/declaration/request_query_registry.py +90 -0
- hare/contrib/request_query/descriptions/__init__.py +11 -0
- hare/contrib/request_query/descriptions/constants.py +11 -0
- hare/contrib/request_query/descriptions/parameter_choice.py +17 -0
- hare/contrib/request_query/descriptions/parameter_describer.py +240 -0
- hare/contrib/request_query/descriptions/parameter_description.py +66 -0
- hare/contrib/request_query/descriptions/relation_description.py +30 -0
- hare/contrib/request_query/enums.py +69 -0
- hare/contrib/request_query/exceptions.py +52 -0
- hare/contrib/request_query/options/__init__.py +33 -0
- hare/contrib/request_query/options/constants.py +25 -0
- hare/contrib/request_query/options/deleted_config.py +90 -0
- hare/contrib/request_query/options/fields_config.py +55 -0
- hare/contrib/request_query/options/filter.py +34 -0
- hare/contrib/request_query/options/filter_field.py +81 -0
- hare/contrib/request_query/options/in_path.py +12 -0
- hare/contrib/request_query/options/include_config.py +56 -0
- hare/contrib/request_query/options/latest_versions.py +71 -0
- hare/contrib/request_query/options/no_filter.py +11 -0
- hare/contrib/request_query/options/ordering_config.py +81 -0
- hare/contrib/request_query/options/parameter_field.py +27 -0
- hare/contrib/request_query/options/request_option.py +152 -0
- hare/contrib/request_query/options/search_config.py +83 -0
- hare/contrib/request_query/paginations/__init__.py +1 -0
- hare/contrib/request_query/paginations/base_offset_pagination.py +78 -0
- hare/contrib/request_query/paginations/constants.py +17 -0
- hare/contrib/request_query/paginations/cursor.py +83 -0
- hare/contrib/request_query/paginations/cursor_pagination.py +184 -0
- hare/contrib/request_query/paginations/offset_pagination.py +31 -0
- hare/contrib/request_query/paginations/pagination.py +120 -0
- hare/contrib/request_query/paginations/scroll_pagination.py +31 -0
- hare/contrib/request_query/request_query.py +1259 -0
- hare/contrib/request_query/results/__init__.py +11 -0
- hare/contrib/request_query/results/cursor_page.py +25 -0
- hare/contrib/request_query/results/page.py +25 -0
- hare/contrib/request_query/results/scroll_page.py +23 -0
- hare/contrib/request_query/row_changes.py +80 -0
- hare/contrib/request_query/types/__init__.py +15 -0
- hare/contrib/request_query/types/comma_separated.py +46 -0
- hare/contrib/request_query/types/constants.py +16 -0
- hare/contrib/request_query/types/generic_target.py +87 -0
- hare/contrib/request_query/types/key_columns.py +60 -0
- hare/contrib/request_query/types/text_parameter.py +18 -0
- hare/contrib/request_query/value_annotation.py +216 -0
- hare/contrib/request_query/value_counter.py +115 -0
- hare/contrib/request_query/value_target.py +50 -0
- hare/contrib/taskiq/__init__.py +15 -0
- hare/contrib/taskiq/constants.py +23 -0
- hare/contrib/taskiq/hare_taskiq.py +76 -0
- hare/contrib/taskiq/hare_taskiq_middleware.py +195 -0
- hare/contrib/taskiq/running_task.py +29 -0
- hare/contrib/taskiq/task_tenant_labels.py +102 -0
- hare/contrib/taskiq/taskiq_delivery.py +117 -0
- hare/contrib/test/__init__.py +39 -0
- hare/contrib/test/conditions/__init__.py +10 -0
- hare/contrib/test/conditions/condition.py +11 -0
- hare/contrib/test/conditions/in_condition.py +21 -0
- hare/contrib/test/conditions/not_eq.py +18 -0
- hare/contrib/test/conditions/not_in.py +21 -0
- hare/contrib/test/constants.py +18 -0
- hare/contrib/test/databases/__init__.py +1 -0
- hare/contrib/test/databases/kept_test_schema.py +51 -0
- hare/contrib/test/databases/model_truncation.py +128 -0
- hare/contrib/test/databases/reusable_test_databases.py +244 -0
- hare/contrib/test/databases/rollback_isolation.py +149 -0
- hare/contrib/test/databases/temporary_databases.py +118 -0
- hare/contrib/test/exceptions.py +5 -0
- hare/contrib/test/features/__init__.py +1 -0
- hare/contrib/test/features/feature_conditions.py +65 -0
- hare/contrib/test/features/feature_requirements.py +84 -0
- hare/contrib/test/isolated_contexts.py +144 -0
- hare/contrib/test/queries/__init__.py +1 -0
- hare/contrib/test/queries/query_counter.py +35 -0
- hare/contrib/test/queries/query_counting.py +59 -0
- hare/contrib/versioning/__init__.py +7 -0
- hare/contrib/versioning/constants.py +5 -0
- hare/contrib/versioning/versioned_model.py +139 -0
- hare/core/__init__.py +4 -0
- hare/core/apps/__init__.py +8 -0
- hare/core/apps/apps.py +693 -0
- hare/core/apps/cross_connection_checks.py +76 -0
- hare/core/apps/model_connection_checks.py +199 -0
- hare/core/apps/model_discovery.py +142 -0
- hare/core/apps/relation_linking.py +773 -0
- hare/core/apps/swappable_models.py +118 -0
- hare/core/apps/table_names.py +39 -0
- hare/core/caching/__init__.py +1 -0
- hare/core/caching/cache.py +426 -0
- hare/core/caching/caches.py +58 -0
- hare/core/caching/constants.py +13 -0
- hare/core/caching/declarations.py +8 -0
- hare/core/caching/forgettable_cache.py +16 -0
- hare/core/caching/model_cache.py +138 -0
- hare/core/config/__init__.py +25 -0
- hare/core/config/app_config.py +64 -0
- hare/core/config/cli_config.py +38 -0
- hare/core/config/config_secrets.py +101 -0
- hare/core/config/config_section.py +37 -0
- hare/core/config/connection_config.py +69 -0
- hare/core/config/constants.py +17 -0
- hare/core/config/db_url_config.py +24 -0
- hare/core/config/hare_config.py +407 -0
- hare/core/config/migration_safety_config.py +54 -0
- hare/core/config/migrations_config.py +72 -0
- hare/core/connections/__init__.py +1 -0
- hare/core/connections/connection_handler.py +457 -0
- hare/core/connections/connection_token.py +36 -0
- hare/core/connections/connections.py +133 -0
- hare/core/constants.py +40 -0
- hare/core/hare.py +205 -0
- hare/core/hare_context.py +854 -0
- hare/core/hare_meta.py +18 -0
- hare/core/log.py +6 -0
- hare/core/registries.py +22 -0
- hare/core/routing/__init__.py +5 -0
- hare/core/routing/connection_router.py +109 -0
- hare/core/routing/primary_reads.py +42 -0
- hare/core/routing/routing.py +28 -0
- hare/core/routing/written_connections.py +63 -0
- hare/ddl/__init__.py +57 -0
- hare/ddl/conditions/__init__.py +1 -0
- hare/ddl/conditions/constraint_condition.py +154 -0
- hare/ddl/conditions/exclusive_arc_condition.py +80 -0
- hare/ddl/conditions/tenant_condition.py +48 -0
- hare/ddl/conditions/trigger_condition.py +44 -0
- hare/ddl/constants.py +68 -0
- hare/ddl/constraints/__init__.py +7 -0
- hare/ddl/constraints/check_constraint.py +38 -0
- hare/ddl/constraints/exclusion_constraint.py +116 -0
- hare/ddl/constraints/foreign_key_constraint.py +39 -0
- hare/ddl/constraints/unique_constraint.py +150 -0
- hare/ddl/ddl_term_sql.py +45 -0
- hare/ddl/declared_names.py +47 -0
- hare/ddl/enums.py +117 -0
- hare/ddl/expressions/__init__.py +0 -0
- hare/ddl/expressions/declared_expressions.py +102 -0
- hare/ddl/expressions/expression_field_renaming.py +150 -0
- hare/ddl/generated_names.py +87 -0
- hare/ddl/indexes/__init__.py +11 -0
- hare/ddl/indexes/index.py +531 -0
- hare/ddl/indexes/ordered_index_key.py +27 -0
- hare/ddl/indexes/partial_index.py +75 -0
- hare/ddl/raw_sql_term.py +44 -0
- hare/ddl/schema_objects/__init__.py +12 -0
- hare/ddl/schema_objects/database_function.py +91 -0
- hare/ddl/schema_objects/database_sequence.py +87 -0
- hare/ddl/schema_objects/dictionary.py +69 -0
- hare/ddl/schema_objects/enum_type.py +24 -0
- hare/ddl/schema_objects/materialized_view.py +52 -0
- hare/ddl/schema_objects/named_schema_object.py +24 -0
- hare/ddl/schema_objects/trigger.py +151 -0
- hare/ddl/schema_objects/view.py +132 -0
- hare/ddl/security/__init__.py +8 -0
- hare/ddl/security/grant.py +106 -0
- hare/ddl/security/policy.py +92 -0
- hare/ddl/table_options.py +364 -0
- hare/dialects/__init__.py +0 -0
- hare/dialects/base/__init__.py +0 -0
- hare/dialects/base/clauses/__init__.py +1 -0
- hare/dialects/base/clauses/enums.py +37 -0
- hare/dialects/base/clauses/limit_returning_conflict_query_clauses.py +194 -0
- hare/dialects/base/clauses/merge_when_sql.py +24 -0
- hare/dialects/base/clauses/query_clauses.py +636 -0
- hare/dialects/base/client/__init__.py +16 -0
- hare/dialects/base/client/connect_failure_reports.py +49 -0
- hare/dialects/base/client/connection_ping.py +48 -0
- hare/dialects/base/client/connection_wrapper.py +126 -0
- hare/dialects/base/client/constants.py +41 -0
- hare/dialects/base/client/database_client.py +1187 -0
- hare/dialects/base/client/declarations.py +37 -0
- hare/dialects/base/client/driver_statement_log_filter.py +33 -0
- hare/dialects/base/client/password_provider.py +144 -0
- hare/dialects/base/client/pool/__init__.py +1 -0
- hare/dialects/base/client/pool/pool_connection_wrapper.py +37 -0
- hare/dialects/base/client/pool/pool_statistics.py +84 -0
- hare/dialects/base/client/pool/pool_timeouts.py +48 -0
- hare/dialects/base/client/transaction_client.py +621 -0
- hare/dialects/base/client/transaction_lifecycle/__init__.py +1 -0
- hare/dialects/base/client/transaction_lifecycle/pending_statements.py +74 -0
- hare/dialects/base/client/transaction_lifecycle/transaction_callbacks.py +128 -0
- hare/dialects/base/client/transaction_lifecycle/transaction_ending.py +360 -0
- hare/dialects/base/connection/__init__.py +1 -0
- hare/dialects/base/connection/connection_option.py +142 -0
- hare/dialects/base/connection/connection_options.py +69 -0
- hare/dialects/base/connection/constants.py +27 -0
- hare/dialects/base/connection/db_url_config_generator.py +194 -0
- hare/dialects/base/connection/driver.py +136 -0
- hare/dialects/base/constants.py +72 -0
- hare/dialects/base/dialect.py +360 -0
- hare/dialects/base/features.py +369 -0
- hare/dialects/base/literals/__init__.py +1 -0
- hare/dialects/base/literals/constants.py +12 -0
- hare/dialects/base/literals/sql_literals.py +254 -0
- hare/dialects/base/lookups/__init__.py +1 -0
- hare/dialects/base/lookups/filter_operators.py +171 -0
- hare/dialects/base/migration_safety/__init__.py +12 -0
- hare/dialects/base/migration_safety/add_field_backfill_rule.py +37 -0
- hare/dialects/base/migration_safety/alter_field_rewrite_rule.py +39 -0
- hare/dialects/base/migration_safety/constants.py +4 -0
- hare/dialects/base/migration_safety/delete_model_rule.py +33 -0
- hare/dialects/base/migration_safety/migration_safety_rule.py +45 -0
- hare/dialects/base/migration_safety/migration_safety_rules.py +72 -0
- hare/dialects/base/migration_safety/remove_field_rule.py +31 -0
- hare/dialects/base/migration_safety/rename_field_rule.py +41 -0
- hare/dialects/base/migration_safety/rename_model_rule.py +42 -0
- hare/dialects/base/migration_safety/run_sql_rule.py +27 -0
- hare/dialects/base/migration_safety/schema_change_with_run_python_rule.py +49 -0
- hare/dialects/base/parameters/__init__.py +1 -0
- hare/dialects/base/parameters/large_in_list.py +147 -0
- hare/dialects/base/parameters/sql_parameters.py +185 -0
- hare/dialects/base/renderers/__init__.py +7 -0
- hare/dialects/base/renderers/checked_term_renderers.py +61 -0
- hare/dialects/base/renderers/json_renderers.py +60 -0
- hare/dialects/base/renderers/term_renderers.py +508 -0
- hare/dialects/base/results/__init__.py +9 -0
- hare/dialects/base/results/described_result.py +22 -0
- hare/dialects/base/results/statement_result.py +53 -0
- hare/dialects/base/schema/__init__.py +0 -0
- hare/dialects/base/schema/base_schema_editor.py +1139 -0
- hare/dialects/base/schema/columns/__init__.py +1 -0
- hare/dialects/base/schema/columns/column_backfill.py +347 -0
- hare/dialects/base/schema/columns/column_conversion_check.py +51 -0
- hare/dialects/base/schema/columns/column_definitions.py +473 -0
- hare/dialects/base/schema/columns/column_narrowing_check.py +178 -0
- hare/dialects/base/schema/columns/column_renames.py +77 -0
- hare/dialects/base/schema/columns/column_type_changes.py +140 -0
- hare/dialects/base/schema/constants.py +30 -0
- hare/dialects/base/schema/constraints/__init__.py +1 -0
- hare/dialects/base/schema/constraints/constraint_names.py +45 -0
- hare/dialects/base/schema/constraints/constraint_statements.py +262 -0
- hare/dialects/base/schema/data/__init__.py +9 -0
- hare/dialects/base/schema/data/model_sql_data.py +41 -0
- hare/dialects/base/schema/data/referencing_key_columns.py +24 -0
- hare/dialects/base/schema/indexes/__init__.py +1 -0
- hare/dialects/base/schema/indexes/generated_index_names.py +180 -0
- hare/dialects/base/schema/indexes/index_statements.py +397 -0
- hare/dialects/base/schema/relations/__init__.py +1 -0
- hare/dialects/base/schema/relations/foreign_key_rebuild.py +480 -0
- hare/dialects/base/schema/relations/many_to_many_through_tables.py +285 -0
- hare/dialects/base/schema/runtime_statements/__init__.py +1 -0
- hare/dialects/base/schema/runtime_statements/table_clearing.py +54 -0
- hare/dialects/base/schema/runtime_statements/table_locks.py +34 -0
- hare/dialects/base/schema/runtime_statements/tenant_conditions.py +71 -0
- hare/dialects/base/schema/schema_editor_part.py +34 -0
- hare/dialects/base/schema/schema_objects/__init__.py +1 -0
- hare/dialects/base/schema/schema_objects/database_functions.py +74 -0
- hare/dialects/base/schema/schema_objects/dictionaries.py +75 -0
- hare/dialects/base/schema/schema_objects/enum_types.py +88 -0
- hare/dialects/base/schema/schema_objects/extensions.py +69 -0
- hare/dialects/base/schema/schema_objects/grants.py +49 -0
- hare/dialects/base/schema/schema_objects/materialized_views.py +111 -0
- hare/dialects/base/schema/schema_objects/row_level_security_policies.py +82 -0
- hare/dialects/base/schema/schema_objects/schemas.py +65 -0
- hare/dialects/base/schema/schema_objects/sequences.py +95 -0
- hare/dialects/base/schema/schema_objects/views.py +81 -0
- hare/dialects/base/schema/shadow/__init__.py +0 -0
- hare/dialects/base/schema/shadow/shadow_database.py +77 -0
- hare/dialects/base/schema/tables/__init__.py +1 -0
- hare/dialects/base/schema/tables/table_comments.py +92 -0
- hare/dialects/base/schema/tables/table_creation.py +742 -0
- hare/dialects/base/schema/tables/table_partitions.py +78 -0
- hare/dialects/base/schema/tables/table_rebuild.py +268 -0
- hare/dialects/base/schema/triggers/__init__.py +1 -0
- hare/dialects/base/schema/triggers/trigger_statements.py +85 -0
- hare/dialects/base/search/__init__.py +1 -0
- hare/dialects/base/search/text_search.py +135 -0
- hare/dialects/base/sql_dialect.py +23 -0
- hare/dialects/base/transactions/__init__.py +1 -0
- hare/dialects/base/transactions/constants.py +5 -0
- hare/dialects/base/transactions/contexts/__init__.py +1 -0
- hare/dialects/base/transactions/contexts/joined_transaction_context.py +36 -0
- hare/dialects/base/transactions/contexts/nested_transaction_context.py +149 -0
- hare/dialects/base/transactions/contexts/non_transactional_context.py +32 -0
- hare/dialects/base/transactions/contexts/top_level_transaction_context.py +79 -0
- hare/dialects/base/transactions/contexts/transaction_context.py +148 -0
- hare/dialects/base/transactions/savepoints/__init__.py +1 -0
- hare/dialects/base/transactions/savepoints/nested_savepoint_lock.py +152 -0
- hare/dialects/base/transactions/savepoints/savepoint_span.py +51 -0
- hare/dialects/base/transactions/transaction_callback.py +32 -0
- hare/dialects/base/transactions/transaction_statements.py +128 -0
- hare/dialects/base/transactions/two_phase_commit.py +134 -0
- hare/dialects/base/types/__init__.py +9 -0
- hare/dialects/base/types/type_mapping.py +63 -0
- hare/dialects/base/types/type_registry.py +395 -0
- hare/dialects/clickhouse/__init__.py +1 -0
- hare/dialects/clickhouse/clauses/__init__.py +1 -0
- hare/dialects/clickhouse/clauses/clickhouse_query_clauses.py +475 -0
- hare/dialects/clickhouse/clauses/constants.py +42 -0
- hare/dialects/clickhouse/clickhouse_dialect.py +260 -0
- hare/dialects/clickhouse/clickhouse_introspector.py +414 -0
- hare/dialects/clickhouse/clickhouse_table_options.py +727 -0
- hare/dialects/clickhouse/client/__init__.py +1 -0
- hare/dialects/clickhouse/client/clickhouse_client.py +913 -0
- hare/dialects/clickhouse/client/clickhouse_connection.py +30 -0
- hare/dialects/clickhouse/client/clickhouse_error_codes.py +26 -0
- hare/dialects/clickhouse/client/clickhouse_external_sets.py +109 -0
- hare/dialects/clickhouse/client/clickhouse_query_templates.py +79 -0
- hare/dialects/clickhouse/client/clickhouse_statement_result.py +15 -0
- hare/dialects/clickhouse/client/clickhouse_streamed_row.py +52 -0
- hare/dialects/clickhouse/client/clickhouse_transaction_client.py +188 -0
- hare/dialects/clickhouse/client/constants.py +211 -0
- hare/dialects/clickhouse/client/declarations.py +47 -0
- hare/dialects/clickhouse/cluster/__init__.py +0 -0
- hare/dialects/clickhouse/cluster/clickhouse_cluster.py +162 -0
- hare/dialects/clickhouse/cluster/clickhouse_cluster_statements.py +154 -0
- hare/dialects/clickhouse/cluster/constants.py +82 -0
- hare/dialects/clickhouse/connection/__init__.py +1 -0
- hare/dialects/clickhouse/connection/clickhouse_driver.py +40 -0
- hare/dialects/clickhouse/constants.py +226 -0
- hare/dialects/clickhouse/drivers/__init__.py +1 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/__init__.py +1 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/clickhouse_connect_driver.py +43 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/client/__init__.py +1 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/client/clickhouse_connect_client.py +390 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/client/clickhouse_connect_dynamic_type.py +76 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/client/clickhouse_connect_totals_query.py +70 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/client/clickhouse_connect_transaction_client.py +56 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/client/clickhouse_connect_whole_response_query.py +127 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/client/clickhouse_json_compact_values.py +96 -0
- hare/dialects/clickhouse/drivers/clickhouse_connect/constants.py +60 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/__init__.py +1 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/clickhouse_driver_driver.py +48 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/__init__.py +1 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_client.py +361 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_client_info.py +70 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_column_types.py +104 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_connections.py +189 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_decompressors.py +48 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_dynamic_column.py +51 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_library_client.py +239 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_library_connection.py +16 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_map_columns.py +49 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_moment_columns.py +85 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_query_result.py +24 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_row_stream.py +127 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_service_block_stream.py +95 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_settings.py +62 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_transaction_client.py +23 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_tuple_columns.py +38 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/client/clickhouse_driver_variant_column.py +76 -0
- hare/dialects/clickhouse/drivers/clickhouse_driver/constants.py +133 -0
- hare/dialects/clickhouse/drivers/clickhouse_shared_variant_values.py +878 -0
- hare/dialects/clickhouse/drivers/constants.py +143 -0
- hare/dialects/clickhouse/enums.py +38 -0
- hare/dialects/clickhouse/fields/__init__.py +43 -0
- hare/dialects/clickhouse/fields/clickhouse_date_field.py +32 -0
- hare/dialects/clickhouse/fields/clickhouse_datetime_field.py +162 -0
- hare/dialects/clickhouse/fields/clickhouse_integer_field.py +20 -0
- hare/dialects/clickhouse/fields/constants.py +31 -0
- hare/dialects/clickhouse/fields/declarations.py +81 -0
- hare/dialects/clickhouse/fields/dynamic_field.py +122 -0
- hare/dialects/clickhouse/fields/fixed_string_field.py +81 -0
- hare/dialects/clickhouse/fields/float32_field.py +39 -0
- hare/dialects/clickhouse/fields/low_cardinality_field.py +72 -0
- hare/dialects/clickhouse/fields/variant_field.py +174 -0
- hare/dialects/clickhouse/functions/__init__.py +39 -0
- hare/dialects/clickhouse/functions/aggregates/__init__.py +37 -0
- hare/dialects/clickhouse/functions/aggregates/arg_extremum.py +23 -0
- hare/dialects/clickhouse/functions/aggregates/declarations.py +120 -0
- hare/dialects/clickhouse/functions/aggregates/group_array.py +48 -0
- hare/dialects/clickhouse/functions/aggregates/median.py +18 -0
- hare/dialects/clickhouse/functions/aggregates/parametric_aggregate.py +48 -0
- hare/dialects/clickhouse/functions/aggregates/parametric_aggregate_function.py +45 -0
- hare/dialects/clickhouse/functions/aggregates/parametric_analytic_function.py +27 -0
- hare/dialects/clickhouse/functions/aggregates/quantile.py +74 -0
- hare/dialects/clickhouse/functions/aggregates/quantiles.py +58 -0
- hare/dialects/clickhouse/functions/aggregates/top_k.py +44 -0
- hare/dialects/clickhouse/functions/dict_get.py +199 -0
- hare/dialects/clickhouse/indexes/__init__.py +19 -0
- hare/dialects/clickhouse/indexes/bloom_filter_index.py +49 -0
- hare/dialects/clickhouse/indexes/clickhouse_index.py +145 -0
- hare/dialects/clickhouse/indexes/constants.py +14 -0
- hare/dialects/clickhouse/indexes/min_max_index.py +22 -0
- hare/dialects/clickhouse/indexes/ngram_bloom_filter_index.py +43 -0
- hare/dialects/clickhouse/indexes/set_index.py +35 -0
- hare/dialects/clickhouse/indexes/token_bloom_filter_index.py +60 -0
- hare/dialects/clickhouse/introspection/__init__.py +0 -0
- hare/dialects/clickhouse/introspection/clickhouse_check_constraints.py +40 -0
- hare/dialects/clickhouse/introspection/clickhouse_observed_table_options.py +280 -0
- hare/dialects/clickhouse/introspection/clickhouse_sql_parts.py +302 -0
- hare/dialects/clickhouse/introspection/clickhouse_type_parser.py +276 -0
- hare/dialects/clickhouse/introspection/constants.py +69 -0
- hare/dialects/clickhouse/keeper/__init__.py +0 -0
- hare/dialects/clickhouse/keeper/clickhouse_migration_lock.py +114 -0
- hare/dialects/clickhouse/keeper/constants.py +38 -0
- hare/dialects/clickhouse/keeper/keeper_codec.py +152 -0
- hare/dialects/clickhouse/keeper/keeper_session.py +213 -0
- hare/dialects/clickhouse/literals/__init__.py +1 -0
- hare/dialects/clickhouse/literals/clickhouse_literals.py +362 -0
- hare/dialects/clickhouse/lookups/__init__.py +0 -0
- hare/dialects/clickhouse/lookups/clickhouse_array_elements_key.py +32 -0
- hare/dialects/clickhouse/lookups/clickhouse_filter_operators.py +49 -0
- hare/dialects/clickhouse/lookups/clickhouse_global_lookups.py +129 -0
- hare/dialects/clickhouse/lookups/clickhouse_json_equality.py +78 -0
- hare/dialects/clickhouse/lookups/clickhouse_json_key_existence.py +38 -0
- hare/dialects/clickhouse/lookups/clickhouse_json_lookups.py +57 -0
- hare/dialects/clickhouse/lookups/clickhouse_json_path_lookups.py +102 -0
- hare/dialects/clickhouse/lookups/clickhouse_json_value_text.py +24 -0
- hare/dialects/clickhouse/lookups/clickhouse_typed_value_lookups.py +213 -0
- hare/dialects/clickhouse/lookups/constants.py +67 -0
- hare/dialects/clickhouse/lookups/declarations.py +14 -0
- hare/dialects/clickhouse/lookups/global_contains_criterion.py +15 -0
- hare/dialects/clickhouse/lookups/in_list/__init__.py +0 -0
- hare/dialects/clickhouse/lookups/in_list/clickhouse_large_in_list.py +95 -0
- hare/dialects/clickhouse/lookups/in_list/clickhouse_value_set_values.py +45 -0
- hare/dialects/clickhouse/migration_safety/__init__.py +9 -0
- hare/dialects/clickhouse/migration_safety/clickhouse_migration_safety_rules.py +34 -0
- hare/dialects/clickhouse/migration_safety/constants.py +10 -0
- hare/dialects/clickhouse/parameters/__init__.py +1 -0
- hare/dialects/clickhouse/parameters/clickhouse_parameters.py +42 -0
- hare/dialects/clickhouse/query/__init__.py +1 -0
- hare/dialects/clickhouse/query/clickhouse_dialect_variants.py +31 -0
- hare/dialects/clickhouse/query/clickhouse_queryset_methods.py +356 -0
- hare/dialects/clickhouse/query/clickhouse_sql_context.py +47 -0
- hare/dialects/clickhouse/query/clickhouse_totals.py +34 -0
- hare/dialects/clickhouse/query/constants.py +24 -0
- hare/dialects/clickhouse/query/declarations.py +21 -0
- hare/dialects/clickhouse/query/totals_result.py +21 -0
- hare/dialects/clickhouse/renderers/__init__.py +1 -0
- hare/dialects/clickhouse/renderers/clickhouse_aggregate_renderers.py +124 -0
- hare/dialects/clickhouse/renderers/clickhouse_assigned_enum_number.py +30 -0
- hare/dialects/clickhouse/renderers/clickhouse_cast_renderers.py +49 -0
- hare/dialects/clickhouse/renderers/clickhouse_checked_integer_result.py +34 -0
- hare/dialects/clickhouse/renderers/clickhouse_condition_renderers.py +27 -0
- hare/dialects/clickhouse/renderers/clickhouse_container_renderers.py +129 -0
- hare/dialects/clickhouse/renderers/clickhouse_json_renderers.py +105 -0
- hare/dialects/clickhouse/renderers/clickhouse_json_texts.py +34 -0
- hare/dialects/clickhouse/renderers/clickhouse_number_renderers.py +76 -0
- hare/dialects/clickhouse/renderers/clickhouse_renderers.py +339 -0
- hare/dialects/clickhouse/renderers/clickhouse_temporal_renderers.py +262 -0
- hare/dialects/clickhouse/renderers/clickhouse_text_renderers.py +117 -0
- hare/dialects/clickhouse/renderers/clickhouse_value_casts.py +115 -0
- hare/dialects/clickhouse/renderers/clickhouse_window_renderers.py +72 -0
- hare/dialects/clickhouse/renderers/constants.py +341 -0
- hare/dialects/clickhouse/schema/__init__.py +1 -0
- hare/dialects/clickhouse/schema/columns/__init__.py +1 -0
- hare/dialects/clickhouse/schema/columns/clickhouse_column_backfill.py +106 -0
- hare/dialects/clickhouse/schema/columns/clickhouse_column_conversion_check.py +173 -0
- hare/dialects/clickhouse/schema/columns/clickhouse_column_definitions.py +62 -0
- hare/dialects/clickhouse/schema/columns/clickhouse_column_narrowing_check.py +109 -0
- hare/dialects/clickhouse/schema/columns/clickhouse_column_renames.py +45 -0
- hare/dialects/clickhouse/schema/constants.py +201 -0
- hare/dialects/clickhouse/schema/declarations.py +95 -0
- hare/dialects/clickhouse/schema/indexes/__init__.py +0 -0
- hare/dialects/clickhouse/schema/indexes/clickhouse_index_statements.py +60 -0
- hare/dialects/clickhouse/schema/runtime_statements/__init__.py +1 -0
- hare/dialects/clickhouse/schema/runtime_statements/clickhouse_table_clearing.py +19 -0
- hare/dialects/clickhouse/schema/schema_objects/__init__.py +0 -0
- hare/dialects/clickhouse/schema/schema_objects/clickhouse_dictionaries.py +169 -0
- hare/dialects/clickhouse/schema/schema_objects/clickhouse_materialized_views.py +221 -0
- hare/dialects/clickhouse/schema/schema_objects/clickhouse_schemas.py +69 -0
- hare/dialects/clickhouse/schema/schema_objects/clickhouse_views.py +59 -0
- hare/dialects/clickhouse/schema/shadow/__init__.py +0 -0
- hare/dialects/clickhouse/schema/shadow/clickhouse_shadow_database.py +155 -0
- hare/dialects/clickhouse/schema/tables/__init__.py +1 -0
- hare/dialects/clickhouse/schema/tables/clickhouse_table_comments.py +43 -0
- hare/dialects/clickhouse/schema/tables/clickhouse_table_creation.py +50 -0
- hare/dialects/clickhouse/schema/tables/clickhouse_table_partitions.py +160 -0
- hare/dialects/clickhouse/schema/tables/clickhouse_table_rebuild.py +227 -0
- hare/dialects/clickhouse/schema_objects/__init__.py +5 -0
- hare/dialects/clickhouse/schema_objects/clickhouse_dictionary.py +118 -0
- hare/dialects/clickhouse/schema_objects/clickhouse_materialized_view.py +159 -0
- hare/dialects/clickhouse/schema_objects/clickhouse_projection.py +204 -0
- hare/dialects/clickhouse/server_versions.py +5 -0
- hare/dialects/clickhouse/spatial/__init__.py +0 -0
- hare/dialects/clickhouse/spatial/clickhouse_geometry_values.py +208 -0
- hare/dialects/clickhouse/spatial/clickhouse_spatial_renderers.py +265 -0
- hare/dialects/clickhouse/spatial/constants.py +66 -0
- hare/dialects/clickhouse/transactions/__init__.py +0 -0
- hare/dialects/clickhouse/transactions/clickhouse_transaction_statements.py +19 -0
- hare/dialects/clickhouse/types/__init__.py +1 -0
- hare/dialects/clickhouse/types/clickhouse_address_values.py +35 -0
- hare/dialects/clickhouse/types/clickhouse_binary_values.py +58 -0
- hare/dialects/clickhouse/types/clickhouse_container_values.py +267 -0
- hare/dialects/clickhouse/types/clickhouse_dynamic_values.py +307 -0
- hare/dialects/clickhouse/types/clickhouse_enum_types.py +232 -0
- hare/dialects/clickhouse/types/clickhouse_json_values.py +202 -0
- hare/dialects/clickhouse/types/clickhouse_low_cardinality_values.py +95 -0
- hare/dialects/clickhouse/types/clickhouse_nullable_types.py +27 -0
- hare/dialects/clickhouse/types/clickhouse_type_names.py +128 -0
- hare/dialects/clickhouse/types/clickhouse_types.py +258 -0
- hare/dialects/clickhouse/types/clickhouse_variant_values.py +128 -0
- hare/dialects/clickhouse/types/constants.py +139 -0
- hare/dialects/clickhouse/types/declarations.py +23 -0
- hare/dialects/constants.py +32 -0
- hare/dialects/dialect_registry.py +340 -0
- hare/dialects/enums.py +34 -0
- hare/dialects/postgresql/__init__.py +0 -0
- hare/dialects/postgresql/clauses/__init__.py +1 -0
- hare/dialects/postgresql/clauses/constants.py +44 -0
- hare/dialects/postgresql/clauses/postgresql_query_clauses.py +114 -0
- hare/dialects/postgresql/client/__init__.py +10 -0
- hare/dialects/postgresql/client/constants.py +328 -0
- hare/dialects/postgresql/client/postgresql_client.py +1224 -0
- hare/dialects/postgresql/client/postgresql_connect_errors.py +66 -0
- hare/dialects/postgresql/client/postgresql_transaction_client.py +80 -0
- hare/dialects/postgresql/client/reusable_test_schemas.py +197 -0
- hare/dialects/postgresql/client/transaction_pooler.py +137 -0
- hare/dialects/postgresql/connection/__init__.py +1 -0
- hare/dialects/postgresql/connection/constants.py +11 -0
- hare/dialects/postgresql/connection/postgresql_driver.py +99 -0
- hare/dialects/postgresql/constants.py +862 -0
- hare/dialects/postgresql/drivers/__init__.py +0 -0
- hare/dialects/postgresql/drivers/asyncpg/__init__.py +0 -0
- hare/dialects/postgresql/drivers/asyncpg/asyncpg_date_codec.py +81 -0
- hare/dialects/postgresql/drivers/asyncpg/asyncpg_driver.py +37 -0
- hare/dialects/postgresql/drivers/asyncpg/asyncpg_extension_type_codecs.py +78 -0
- hare/dialects/postgresql/drivers/asyncpg/asyncpg_hstore_codec.py +84 -0
- hare/dialects/postgresql/drivers/asyncpg/asyncpg_interval_codec.py +72 -0
- hare/dialects/postgresql/drivers/asyncpg/asyncpg_timestamp_codec.py +74 -0
- hare/dialects/postgresql/drivers/asyncpg/asyncpg_timestamptz_codec.py +88 -0
- hare/dialects/postgresql/drivers/asyncpg/asyncpg_tsvector_codec.py +264 -0
- hare/dialects/postgresql/drivers/asyncpg/client/__init__.py +9 -0
- hare/dialects/postgresql/drivers/asyncpg/client/asyncpg_client.py +738 -0
- hare/dialects/postgresql/drivers/asyncpg/client/asyncpg_transaction_client.py +197 -0
- hare/dialects/postgresql/drivers/asyncpg/constants.py +150 -0
- hare/dialects/postgresql/drivers/asyncpg/pre_epoch_local_zone.py +27 -0
- hare/dialects/postgresql/drivers/constants.py +22 -0
- hare/dialects/postgresql/drivers/rust_pg/__init__.py +0 -0
- hare/dialects/postgresql/drivers/rust_pg/client/__init__.py +9 -0
- hare/dialects/postgresql/drivers/rust_pg/client/rust_pg_client.py +461 -0
- hare/dialects/postgresql/drivers/rust_pg/client/rust_pg_transaction_client.py +306 -0
- hare/dialects/postgresql/drivers/rust_pg/client/rust_pg_transaction_connection_wrapper.py +53 -0
- hare/dialects/postgresql/drivers/rust_pg/constants.py +43 -0
- hare/dialects/postgresql/drivers/rust_pg/rust_pg_driver.py +66 -0
- hare/dialects/postgresql/enums.py +99 -0
- hare/dialects/postgresql/fields/__init__.py +68 -0
- hare/dialects/postgresql/fields/citext_field.py +42 -0
- hare/dialects/postgresql/fields/constants.py +115 -0
- hare/dialects/postgresql/fields/fixed_char_field.py +23 -0
- hare/dialects/postgresql/fields/hstore/__init__.py +5 -0
- hare/dialects/postgresql/fields/hstore/h_store_field.py +105 -0
- hare/dialects/postgresql/fields/hstore/h_store_text.py +86 -0
- hare/dialects/postgresql/fields/interval_field.py +31 -0
- hare/dialects/postgresql/fields/ltree_field.py +98 -0
- hare/dialects/postgresql/fields/multiranges/__init__.py +19 -0
- hare/dialects/postgresql/fields/multiranges/declarations.py +55 -0
- hare/dialects/postgresql/fields/multiranges/multi_range_field.py +326 -0
- hare/dialects/postgresql/fields/naive_datetime_field.py +74 -0
- hare/dialects/postgresql/fields/naive_time_field.py +64 -0
- hare/dialects/postgresql/fields/native_enum/__init__.py +5 -0
- hare/dialects/postgresql/fields/native_enum/native_enum_field.py +23 -0
- hare/dialects/postgresql/fields/native_enum/native_enum_field_instance.py +87 -0
- hare/dialects/postgresql/fields/network/__init__.py +7 -0
- hare/dialects/postgresql/fields/network/cidr_field.py +24 -0
- hare/dialects/postgresql/fields/network/inet_field.py +25 -0
- hare/dialects/postgresql/fields/network/mac_address_field.py +59 -0
- hare/dialects/postgresql/fields/network/network_field.py +80 -0
- hare/dialects/postgresql/fields/postgis_field.py +206 -0
- hare/dialects/postgresql/fields/ranges/__init__.py +19 -0
- hare/dialects/postgresql/fields/ranges/date_range_field.py +48 -0
- hare/dialects/postgresql/fields/ranges/date_time_range_field.py +153 -0
- hare/dialects/postgresql/fields/ranges/decimal_range_field.py +42 -0
- hare/dialects/postgresql/fields/ranges/declarations.py +15 -0
- hare/dialects/postgresql/fields/ranges/int_range_field.py +60 -0
- hare/dialects/postgresql/fields/ranges/range.py +26 -0
- hare/dialects/postgresql/fields/ranges/range_field.py +349 -0
- hare/dialects/postgresql/fields/ts_vector_field.py +143 -0
- hare/dialects/postgresql/functions/__init__.py +72 -0
- hare/dialects/postgresql/functions/aggregates/__init__.py +21 -0
- hare/dialects/postgresql/functions/aggregates/declarations.py +67 -0
- hare/dialects/postgresql/functions/aggregates/jsonb_agg.py +35 -0
- hare/dialects/postgresql/functions/aggregates/jsonb_agg_field.py +29 -0
- hare/dialects/postgresql/functions/aggregates/range_agg.py +22 -0
- hare/dialects/postgresql/functions/aggregates/string_agg.py +101 -0
- hare/dialects/postgresql/functions/aggregates/string_agg_function.py +13 -0
- hare/dialects/postgresql/functions/array/__init__.py +13 -0
- hare/dialects/postgresql/functions/array/any_value.py +13 -0
- hare/dialects/postgresql/functions/array/array_slice.py +28 -0
- hare/dialects/postgresql/functions/array/array_subquery.py +62 -0
- hare/dialects/postgresql/functions/array/array_subscript.py +66 -0
- hare/dialects/postgresql/functions/constants.py +8 -0
- hare/dialects/postgresql/functions/ltree/__init__.py +7 -0
- hare/dialects/postgresql/functions/ltree/subpath.py +54 -0
- hare/dialects/postgresql/functions/random_uuid.py +26 -0
- hare/dialects/postgresql/functions/spatial/__init__.py +9 -0
- hare/dialects/postgresql/functions/spatial/st_distance.py +63 -0
- hare/dialects/postgresql/functions/spatial/std_within.py +46 -0
- hare/dialects/postgresql/functions/statistics/__init__.py +31 -0
- hare/dialects/postgresql/functions/statistics/covar_pop.py +49 -0
- hare/dialects/postgresql/functions/statistics/declarations.py +84 -0
- hare/dialects/postgresql/functions/statistics/regr_count.py +21 -0
- hare/dialects/postgresql/functions/statistics/statistic_pair_aggregate.py +55 -0
- hare/dialects/postgresql/functions/transaction_now.py +27 -0
- hare/dialects/postgresql/functions/trigram/__init__.py +21 -0
- hare/dialects/postgresql/functions/trigram/declarations.py +53 -0
- hare/dialects/postgresql/functions/trigram/trigram_function.py +61 -0
- hare/dialects/postgresql/functions/trigram/trigram_word_similarity.py +19 -0
- hare/dialects/postgresql/indexes/__init__.py +25 -0
- hare/dialects/postgresql/indexes/constants.py +16 -0
- hare/dialects/postgresql/indexes/declarations.py +36 -0
- hare/dialects/postgresql/indexes/hnsw_index.py +63 -0
- hare/dialects/postgresql/indexes/ivfflat_index.py +37 -0
- hare/dialects/postgresql/indexes/postgresql_index.py +112 -0
- hare/dialects/postgresql/introspection/__init__.py +0 -0
- hare/dialects/postgresql/introspection/postgresql_array_literals.py +101 -0
- hare/dialects/postgresql/introspection/postgresql_definitions.py +193 -0
- hare/dialects/postgresql/introspection/postgresql_inspected_schema_objects.py +196 -0
- hare/dialects/postgresql/introspection/postgresql_object_parts.py +102 -0
- hare/dialects/postgresql/literals/__init__.py +1 -0
- hare/dialects/postgresql/literals/postgresql_literals.py +99 -0
- hare/dialects/postgresql/lookups/__init__.py +0 -0
- hare/dialects/postgresql/lookups/array/__init__.py +5 -0
- hare/dialects/postgresql/lookups/array/array_length.py +26 -0
- hare/dialects/postgresql/lookups/constants.py +44 -0
- hare/dialects/postgresql/lookups/hstore/__init__.py +11 -0
- hare/dialects/postgresql/lookups/hstore/h_store_value_term.py +18 -0
- hare/dialects/postgresql/lookups/hstore/postgresql_h_store_field_lookups.py +75 -0
- hare/dialects/postgresql/lookups/hstore/postgresql_h_store_lookups.py +38 -0
- hare/dialects/postgresql/lookups/in_list/__init__.py +11 -0
- hare/dialects/postgresql/lookups/in_list/array_parameter.py +104 -0
- hare/dialects/postgresql/lookups/in_list/postgresql_large_in_list.py +78 -0
- hare/dialects/postgresql/lookups/in_list/unnest_row_values.py +32 -0
- hare/dialects/postgresql/lookups/json/__init__.py +9 -0
- hare/dialects/postgresql/lookups/json/postgresql_json_filter_guards.py +111 -0
- hare/dialects/postgresql/lookups/json/postgresql_json_lookups.py +59 -0
- hare/dialects/postgresql/lookups/ltree/__init__.py +9 -0
- hare/dialects/postgresql/lookups/ltree/postgresql_ltree_field_lookups.py +54 -0
- hare/dialects/postgresql/lookups/ltree/postgresql_ltree_lookups.py +35 -0
- hare/dialects/postgresql/lookups/multiranges/__init__.py +9 -0
- hare/dialects/postgresql/lookups/multiranges/postgresql_multi_range_field_lookups.py +50 -0
- hare/dialects/postgresql/lookups/network/__init__.py +1 -0
- hare/dialects/postgresql/lookups/network/postgresql_network_field_lookups.py +46 -0
- hare/dialects/postgresql/lookups/network/postgresql_network_lookups.py +35 -0
- hare/dialects/postgresql/lookups/postgresql_filter_operators.py +96 -0
- hare/dialects/postgresql/lookups/postgresql_regex_lookups.py +22 -0
- hare/dialects/postgresql/lookups/postgresql_value_encoders.py +163 -0
- hare/dialects/postgresql/lookups/ranges/__init__.py +9 -0
- hare/dialects/postgresql/lookups/ranges/postgresql_range_field_lookups.py +49 -0
- hare/dialects/postgresql/lookups/ranges/postgresql_range_lookups.py +49 -0
- hare/dialects/postgresql/lookups/trigram/__init__.py +1 -0
- hare/dialects/postgresql/lookups/trigram/postgresql_trigram_lookups.py +69 -0
- hare/dialects/postgresql/lookups/trigram/trigram_operator_term.py +16 -0
- hare/dialects/postgresql/lookups/unaccent_transform.py +39 -0
- hare/dialects/postgresql/migration_safety/__init__.py +9 -0
- hare/dialects/postgresql/migration_safety/check_constraint_validation_rule.py +36 -0
- hare/dialects/postgresql/migration_safety/constants.py +18 -0
- hare/dialects/postgresql/migration_safety/foreign_key_validation_rule.py +74 -0
- hare/dialects/postgresql/migration_safety/index_without_concurrently_rule.py +45 -0
- hare/dialects/postgresql/migration_safety/postgresql_migration_safety_rules.py +59 -0
- hare/dialects/postgresql/migration_safety/set_not_null_rule.py +47 -0
- hare/dialects/postgresql/migration_safety/unique_constraint_index_rule.py +65 -0
- hare/dialects/postgresql/migration_safety/volatile_default_rule.py +40 -0
- hare/dialects/postgresql/parameters/__init__.py +1 -0
- hare/dialects/postgresql/parameters/constants.py +83 -0
- hare/dialects/postgresql/parameters/postgresql_parameters.py +86 -0
- hare/dialects/postgresql/partitioning/__init__.py +23 -0
- hare/dialects/postgresql/partitioning/constants.py +56 -0
- hare/dialects/postgresql/partitioning/explicit_partitioning.py +97 -0
- hare/dialects/postgresql/partitioning/hash_partitioning.py +50 -0
- hare/dialects/postgresql/partitioning/list_partitioning.py +55 -0
- hare/dialects/postgresql/partitioning/observed_partitioning.py +205 -0
- hare/dialects/postgresql/partitioning/partitioning.py +280 -0
- hare/dialects/postgresql/partitioning/partitions/__init__.py +1 -0
- hare/dialects/postgresql/partitioning/partitions/default_partition.py +30 -0
- hare/dialects/postgresql/partitioning/partitions/list_partition.py +36 -0
- hare/dialects/postgresql/partitioning/partitions/partition.py +46 -0
- hare/dialects/postgresql/partitioning/partitions/range_partition.py +94 -0
- hare/dialects/postgresql/partitioning/range_partitioning.py +60 -0
- hare/dialects/postgresql/postgresql_dialect.py +207 -0
- hare/dialects/postgresql/postgresql_introspector.py +1055 -0
- hare/dialects/postgresql/postgresql_table_options.py +165 -0
- hare/dialects/postgresql/query/__init__.py +7 -0
- hare/dialects/postgresql/query/declarations.py +13 -0
- hare/dialects/postgresql/renderers/__init__.py +7 -0
- hare/dialects/postgresql/renderers/constants.py +43 -0
- hare/dialects/postgresql/renderers/postgresql_container_renderers.py +90 -0
- hare/dialects/postgresql/renderers/postgresql_defaults.py +88 -0
- hare/dialects/postgresql/renderers/postgresql_json_renderers.py +57 -0
- hare/dialects/postgresql/renderers/postgresql_number_renderers.py +58 -0
- hare/dialects/postgresql/renderers/postgresql_renderers.py +82 -0
- hare/dialects/postgresql/renderers/postgresql_temporal_renderers.py +179 -0
- hare/dialects/postgresql/renderers/postgresql_text_renderers.py +67 -0
- hare/dialects/postgresql/request_query/__init__.py +8 -0
- hare/dialects/postgresql/request_query/declarations.py +17 -0
- hare/dialects/postgresql/schema/__init__.py +0 -0
- hare/dialects/postgresql/schema/columns/__init__.py +1 -0
- hare/dialects/postgresql/schema/columns/postgresql_column_backfill.py +13 -0
- hare/dialects/postgresql/schema/columns/postgresql_column_narrowing_check.py +42 -0
- hare/dialects/postgresql/schema/columns/postgresql_column_type_changes.py +129 -0
- hare/dialects/postgresql/schema/constants.py +384 -0
- hare/dialects/postgresql/schema/constraints/__init__.py +1 -0
- hare/dialects/postgresql/schema/constraints/postgresql_constraint_statements.py +119 -0
- hare/dialects/postgresql/schema/indexes/__init__.py +1 -0
- hare/dialects/postgresql/schema/indexes/postgresql_index_statements.py +24 -0
- hare/dialects/postgresql/schema/postgresql_schema_editor.py +280 -0
- hare/dialects/postgresql/schema/relations/__init__.py +1 -0
- hare/dialects/postgresql/schema/relations/postgresql_foreign_key_rebuild.py +230 -0
- hare/dialects/postgresql/schema/runtime_statements/__init__.py +1 -0
- hare/dialects/postgresql/schema/runtime_statements/postgresql_foreign_key_deferral.py +109 -0
- hare/dialects/postgresql/schema/runtime_statements/postgresql_table_clearing.py +80 -0
- hare/dialects/postgresql/schema/runtime_statements/postgresql_table_locks.py +27 -0
- hare/dialects/postgresql/schema/runtime_statements/postgresql_tenant_conditions.py +34 -0
- hare/dialects/postgresql/schema/schema_objects/__init__.py +1 -0
- hare/dialects/postgresql/schema/schema_objects/postgresql_database_functions.py +95 -0
- hare/dialects/postgresql/schema/schema_objects/postgresql_enum_types.py +130 -0
- hare/dialects/postgresql/schema/schema_objects/postgresql_extensions.py +35 -0
- hare/dialects/postgresql/schema/schema_objects/postgresql_grants.py +89 -0
- hare/dialects/postgresql/schema/schema_objects/postgresql_materialized_views.py +107 -0
- hare/dialects/postgresql/schema/schema_objects/postgresql_row_level_security_policies.py +125 -0
- hare/dialects/postgresql/schema/schema_objects/postgresql_schemas.py +51 -0
- hare/dialects/postgresql/schema/schema_objects/postgresql_sequences.py +132 -0
- hare/dialects/postgresql/schema/schema_objects/postgresql_views.py +53 -0
- hare/dialects/postgresql/schema/shadow/__init__.py +0 -0
- hare/dialects/postgresql/schema/shadow/postgresql_shadow_database.py +78 -0
- hare/dialects/postgresql/schema/tables/__init__.py +1 -0
- hare/dialects/postgresql/schema/tables/postgresql_table_comments.py +74 -0
- hare/dialects/postgresql/schema/tables/postgresql_table_partitions.py +229 -0
- hare/dialects/postgresql/schema/tables/postgresql_table_rebuild.py +118 -0
- hare/dialects/postgresql/schema/triggers/__init__.py +1 -0
- hare/dialects/postgresql/schema/triggers/postgresql_trigger_statements.py +141 -0
- hare/dialects/postgresql/search/__init__.py +8 -0
- hare/dialects/postgresql/search/constants.py +43 -0
- hare/dialects/postgresql/search/criterion/__init__.py +14 -0
- hare/dialects/postgresql/search/criterion/declarations.py +14 -0
- hare/dialects/postgresql/search/criterion/search_criterion.py +62 -0
- hare/dialects/postgresql/search/criterion/ts_query_function.py +20 -0
- hare/dialects/postgresql/search/criterion/ts_query_invert.py +32 -0
- hare/dialects/postgresql/search/enums.py +12 -0
- hare/dialects/postgresql/search/functions/__init__.py +9 -0
- hare/dialects/postgresql/search/functions/plain_to_ts_query.py +18 -0
- hare/dialects/postgresql/search/functions/to_ts_vector.py +20 -0
- hare/dialects/postgresql/search/lexemes/__init__.py +1 -0
- hare/dialects/postgresql/search/lexemes/combined_lexeme.py +35 -0
- hare/dialects/postgresql/search/lexemes/lexeme.py +77 -0
- hare/dialects/postgresql/search/lexemes/lexeme_combinable.py +59 -0
- hare/dialects/postgresql/search/postgresql_text_search.py +237 -0
- hare/dialects/postgresql/search/ts_vector_expression_reader.py +106 -0
- hare/dialects/postgresql/server_versions.py +26 -0
- hare/dialects/postgresql/spatial/__init__.py +7 -0
- hare/dialects/postgresql/spatial/constants.py +118 -0
- hare/dialects/postgresql/spatial/postgresql_spatial_renderers.py +102 -0
- hare/dialects/postgresql/transactions/__init__.py +1 -0
- hare/dialects/postgresql/transactions/constants.py +21 -0
- hare/dialects/postgresql/transactions/postgresql_transaction_statements.py +40 -0
- hare/dialects/postgresql/transactions/postgresql_two_phase_commit.py +87 -0
- hare/dialects/postgresql/types/__init__.py +1 -0
- hare/dialects/postgresql/types/postgresql_container_values.py +104 -0
- hare/dialects/postgresql/types/postgresql_types.py +213 -0
- hare/dialects/postgresql/validators/__init__.py +15 -0
- hare/dialects/postgresql/validators/keys_validator.py +32 -0
- hare/dialects/postgresql/validators/range_bound_validator.py +33 -0
- hare/dialects/postgresql/validators/range_max_value_validator.py +17 -0
- hare/dialects/postgresql/validators/range_min_value_validator.py +17 -0
- hare/dialects/postgresql/vectors/__init__.py +1 -0
- hare/dialects/postgresql/vectors/constants.py +13 -0
- hare/dialects/postgresql/vectors/postgresql_vector_renderers.py +40 -0
- hare/dialects/postgresql/vectors/postgresql_vector_values.py +94 -0
- hare/dialects/sqlite/__init__.py +0 -0
- hare/dialects/sqlite/clauses/__init__.py +1 -0
- hare/dialects/sqlite/clauses/constants.py +7 -0
- hare/dialects/sqlite/clauses/sqlite_query_clauses.py +100 -0
- hare/dialects/sqlite/client/__init__.py +12 -0
- hare/dialects/sqlite/client/constants.py +103 -0
- hare/dialects/sqlite/client/declarations.py +27 -0
- hare/dialects/sqlite/client/sqlite_client.py +507 -0
- hare/dialects/sqlite/client/sqlite_migration_lock.py +76 -0
- hare/dialects/sqlite/client/sqlite_transaction_client.py +160 -0
- hare/dialects/sqlite/connection/__init__.py +1 -0
- hare/dialects/sqlite/connection/constants.py +7 -0
- hare/dialects/sqlite/connection/sqlite_driver.py +59 -0
- hare/dialects/sqlite/constants.py +451 -0
- hare/dialects/sqlite/drivers/__init__.py +1 -0
- hare/dialects/sqlite/drivers/aiosqlite/__init__.py +1 -0
- hare/dialects/sqlite/drivers/aiosqlite/aiosqlite_driver.py +41 -0
- hare/dialects/sqlite/drivers/aiosqlite/client/__init__.py +23 -0
- hare/dialects/sqlite/drivers/aiosqlite/client/aiosqlite_client.py +428 -0
- hare/dialects/sqlite/drivers/aiosqlite/client/aiosqlite_client_with_regexp_support.py +16 -0
- hare/dialects/sqlite/drivers/aiosqlite/client/aiosqlite_connection_wrapper.py +62 -0
- hare/dialects/sqlite/drivers/aiosqlite/client/aiosqlite_statement_timeout_connection_wrapper.py +53 -0
- hare/dialects/sqlite/drivers/aiosqlite/client/aiosqlite_transaction_client.py +176 -0
- hare/dialects/sqlite/drivers/aiosqlite/client/aiosqlite_transaction_connection_wrapper.py +23 -0
- hare/dialects/sqlite/drivers/aiosqlite/constants.py +11 -0
- hare/dialects/sqlite/drivers/constants.py +19 -0
- hare/dialects/sqlite/enums.py +37 -0
- hare/dialects/sqlite/exceptions.py +10 -0
- hare/dialects/sqlite/functions/__init__.py +0 -0
- hare/dialects/sqlite/functions/comparison/__init__.py +11 -0
- hare/dialects/sqlite/functions/comparison/sqlite_cast.py +204 -0
- hare/dialects/sqlite/functions/comparison/sqlite_greatest_least.py +63 -0
- hare/dialects/sqlite/functions/constants.py +102 -0
- hare/dialects/sqlite/functions/datetime/__init__.py +13 -0
- hare/dialects/sqlite/functions/datetime/date_truncation.py +115 -0
- hare/dialects/sqlite/functions/datetime/sqlite_date_part_extraction.py +77 -0
- hare/dialects/sqlite/functions/datetime/sqlite_date_timestamp.py +48 -0
- hare/dialects/sqlite/functions/datetime/sqlite_local_now.py +54 -0
- hare/dialects/sqlite/functions/datetime/temporal_arithmetic_functions.py +147 -0
- hare/dialects/sqlite/functions/decimal/__init__.py +1 -0
- hare/dialects/sqlite/functions/decimal/sqlite_decimal_arithmetic.py +152 -0
- hare/dialects/sqlite/functions/decimal/sqlite_decimal_average.py +23 -0
- hare/dialects/sqlite/functions/decimal/sqlite_decimal_collation.py +125 -0
- hare/dialects/sqlite/functions/decimal/sqlite_decimal_comparand.py +23 -0
- hare/dialects/sqlite/functions/decimal/sqlite_decimal_operation.py +33 -0
- hare/dialects/sqlite/functions/decimal/sqlite_decimal_round.py +50 -0
- hare/dialects/sqlite/functions/decimal/sqlite_decimal_storage.py +77 -0
- hare/dialects/sqlite/functions/decimal/sqlite_decimal_sum.py +62 -0
- hare/dialects/sqlite/functions/decimal/sqlite_decimal_text.py +22 -0
- hare/dialects/sqlite/functions/decimal/sqlite_stored_decimal.py +29 -0
- hare/dialects/sqlite/functions/json/__init__.py +9 -0
- hare/dialects/sqlite/functions/json/sqlite_json_datetime.py +124 -0
- hare/dialects/sqlite/functions/json/sqlite_json_path.py +116 -0
- hare/dialects/sqlite/functions/regex/__init__.py +5 -0
- hare/dialects/sqlite/functions/regex/sqlite_posix_regex.py +102 -0
- hare/dialects/sqlite/functions/regex/sqlite_regex_criterion.py +18 -0
- hare/dialects/sqlite/functions/sqlite_checked_integer.py +15 -0
- hare/dialects/sqlite/functions/sqlite_collation.py +51 -0
- hare/dialects/sqlite/functions/sqlite_connection_function.py +17 -0
- hare/dialects/sqlite/functions/sqlite_function_errors.py +45 -0
- hare/dialects/sqlite/functions/sqlite_integer_range.py +48 -0
- hare/dialects/sqlite/functions/sqlite_math_functions.py +233 -0
- hare/dialects/sqlite/functions/sqlite_native_functions.py +12 -0
- hare/dialects/sqlite/functions/sqlite_sort_keys.py +58 -0
- hare/dialects/sqlite/functions/statistics/__init__.py +19 -0
- hare/dialects/sqlite/functions/statistics/declarations.py +31 -0
- hare/dialects/sqlite/functions/statistics/sqlite_statistic.py +118 -0
- hare/dialects/sqlite/functions/statistics/sqlite_statistics.py +51 -0
- hare/dialects/sqlite/functions/text/__init__.py +1 -0
- hare/dialects/sqlite/functions/text/sqlite_text_functions.py +140 -0
- hare/dialects/sqlite/indexes/__init__.py +7 -0
- hare/dialects/sqlite/indexes/constants.py +45 -0
- hare/dialects/sqlite/indexes/full_text_index.py +228 -0
- hare/dialects/sqlite/indexes/separate_table_index.py +105 -0
- hare/dialects/sqlite/indexes/spatialite_index.py +228 -0
- hare/dialects/sqlite/literals/__init__.py +1 -0
- hare/dialects/sqlite/literals/sqlite_literals.py +51 -0
- hare/dialects/sqlite/lookups/__init__.py +0 -0
- hare/dialects/sqlite/lookups/constants.py +18 -0
- hare/dialects/sqlite/lookups/in_list/__init__.py +11 -0
- hare/dialects/sqlite/lookups/in_list/json_array_row_values.py +39 -0
- hare/dialects/sqlite/lookups/in_list/json_array_values.py +116 -0
- hare/dialects/sqlite/lookups/in_list/sqlite_large_in_list.py +96 -0
- hare/dialects/sqlite/lookups/json/__init__.py +1 -0
- hare/dialects/sqlite/lookups/json/sqlite_json_filter_guards.py +128 -0
- hare/dialects/sqlite/lookups/json/sqlite_json_lookups.py +51 -0
- hare/dialects/sqlite/lookups/json/sqlite_json_path_lookups.py +56 -0
- hare/dialects/sqlite/lookups/json/sqlite_json_type_criterion.py +13 -0
- hare/dialects/sqlite/lookups/sqlite_filter_operators.py +89 -0
- hare/dialects/sqlite/migration_safety/__init__.py +9 -0
- hare/dialects/sqlite/migration_safety/sqlite_migration_safety_rules.py +32 -0
- hare/dialects/sqlite/parameters/__init__.py +1 -0
- hare/dialects/sqlite/parameters/constants.py +11 -0
- hare/dialects/sqlite/parameters/sqlite_parameter_adapters.py +61 -0
- hare/dialects/sqlite/parameters/sqlite_parameters.py +27 -0
- hare/dialects/sqlite/query/__init__.py +7 -0
- hare/dialects/sqlite/query/declarations.py +13 -0
- hare/dialects/sqlite/renderers/__init__.py +7 -0
- hare/dialects/sqlite/renderers/constants.py +43 -0
- hare/dialects/sqlite/renderers/sqlite_defaults.py +84 -0
- hare/dialects/sqlite/renderers/sqlite_json_renderers.py +142 -0
- hare/dialects/sqlite/renderers/sqlite_number_renderers.py +137 -0
- hare/dialects/sqlite/renderers/sqlite_renderers.py +235 -0
- hare/dialects/sqlite/renderers/sqlite_temporal_renderers.py +138 -0
- hare/dialects/sqlite/renderers/sqlite_text_renderers.py +60 -0
- hare/dialects/sqlite/request_query/__init__.py +8 -0
- hare/dialects/sqlite/request_query/declarations.py +16 -0
- hare/dialects/sqlite/schema/__init__.py +0 -0
- hare/dialects/sqlite/schema/columns/__init__.py +1 -0
- hare/dialects/sqlite/schema/columns/sqlite_column_backfill.py +29 -0
- hare/dialects/sqlite/schema/columns/sqlite_column_conversion_check.py +181 -0
- hare/dialects/sqlite/schema/columns/sqlite_column_narrowing_check.py +24 -0
- hare/dialects/sqlite/schema/columns/sqlite_column_type_changes.py +148 -0
- hare/dialects/sqlite/schema/constants.py +108 -0
- hare/dialects/sqlite/schema/constraints/__init__.py +1 -0
- hare/dialects/sqlite/schema/constraints/sqlite_constraint_statements.py +32 -0
- hare/dialects/sqlite/schema/indexes/__init__.py +1 -0
- hare/dialects/sqlite/schema/indexes/sqlite_generated_index_names.py +61 -0
- hare/dialects/sqlite/schema/indexes/sqlite_index_statements.py +78 -0
- hare/dialects/sqlite/schema/relations/__init__.py +1 -0
- hare/dialects/sqlite/schema/relations/sqlite_foreign_key_rebuild.py +100 -0
- hare/dialects/sqlite/schema/runtime_statements/__init__.py +1 -0
- hare/dialects/sqlite/schema/runtime_statements/sqlite_foreign_key_deferral.py +87 -0
- hare/dialects/sqlite/schema/runtime_statements/sqlite_table_clearing.py +39 -0
- hare/dialects/sqlite/schema/runtime_statements/sqlite_tenant_conditions.py +21 -0
- hare/dialects/sqlite/schema/shadow/__init__.py +0 -0
- hare/dialects/sqlite/schema/shadow/sqlite_shadow_database.py +36 -0
- hare/dialects/sqlite/schema/sqlite_schema_editor.py +492 -0
- hare/dialects/sqlite/schema/tables/__init__.py +1 -0
- hare/dialects/sqlite/schema/tables/sqlite_table_comments.py +32 -0
- hare/dialects/sqlite/schema/tables/sqlite_table_rebuild.py +164 -0
- hare/dialects/sqlite/schema/triggers/__init__.py +1 -0
- hare/dialects/sqlite/schema/triggers/sqlite_trigger_statements.py +70 -0
- hare/dialects/sqlite/search/__init__.py +8 -0
- hare/dialects/sqlite/search/constants.py +33 -0
- hare/dialects/sqlite/search/sqlite_full_text_query.py +137 -0
- hare/dialects/sqlite/search/sqlite_search_renderers.py +33 -0
- hare/dialects/sqlite/search/sqlite_text_search.py +308 -0
- hare/dialects/sqlite/search/terms/__init__.py +1 -0
- hare/dialects/sqlite/search/terms/full_text_headline.py +56 -0
- hare/dialects/sqlite/search/terms/full_text_match.py +73 -0
- hare/dialects/sqlite/search/terms/full_text_query.py +42 -0
- hare/dialects/sqlite/search/terms/full_text_query_combination.py +82 -0
- hare/dialects/sqlite/search/terms/full_text_rank.py +34 -0
- hare/dialects/sqlite/search/terms/full_text_row_value.py +104 -0
- hare/dialects/sqlite/server_versions.py +17 -0
- hare/dialects/sqlite/spatial/__init__.py +0 -0
- hare/dialects/sqlite/spatial/constants.py +173 -0
- hare/dialects/sqlite/spatial/spatialite_blob_reader.py +166 -0
- hare/dialects/sqlite/spatial/spatialite_blob_writer.py +105 -0
- hare/dialects/sqlite/spatial/sqlite_geometry_values.py +75 -0
- hare/dialects/sqlite/spatial/sqlite_spatial_extension.py +116 -0
- hare/dialects/sqlite/spatial/sqlite_spatial_renderers.py +202 -0
- hare/dialects/sqlite/sqlite_dialect.py +138 -0
- hare/dialects/sqlite/sqlite_introspector.py +1025 -0
- hare/dialects/sqlite/sqlite_table_options.py +92 -0
- hare/dialects/sqlite/table_option_constants.py +15 -0
- hare/dialects/sqlite/transactions/__init__.py +1 -0
- hare/dialects/sqlite/transactions/constants.py +10 -0
- hare/dialects/sqlite/transactions/sqlite_transaction_statements.py +19 -0
- hare/dialects/sqlite/types/__init__.py +1 -0
- hare/dialects/sqlite/types/sqlite_types.py +87 -0
- hare/dialects/sqlite/vectors/__init__.py +1 -0
- hare/dialects/sqlite/vectors/constants.py +16 -0
- hare/dialects/sqlite/vectors/sqlite_vector_extension.py +112 -0
- hare/dialects/sqlite/vectors/sqlite_vector_renderers.py +55 -0
- hare/dialects/sqlite/vectors/sqlite_vector_values.py +113 -0
- hare/exceptions.py +397 -0
- hare/fields/__init__.py +133 -0
- hare/fields/composite_primary_key.py +40 -0
- hare/fields/constants.py +120 -0
- hare/fields/data/__init__.py +3 -0
- hare/fields/data/binary_field.py +62 -0
- hare/fields/data/boolean_field.py +57 -0
- hare/fields/data/choices/__init__.py +16 -0
- hare/fields/data/choices/char_enum_field.py +27 -0
- hare/fields/data/choices/char_enum_field_instance.py +117 -0
- hare/fields/data/choices/int_enum_field.py +23 -0
- hare/fields/data/choices/int_enum_field_instance.py +102 -0
- hare/fields/data/constants.py +122 -0
- hare/fields/data/containers/__init__.py +10 -0
- hare/fields/data/containers/array_field.py +152 -0
- hare/fields/data/containers/constants.py +25 -0
- hare/fields/data/containers/container_field.py +342 -0
- hare/fields/data/containers/declarations.py +13 -0
- hare/fields/data/containers/map_field.py +165 -0
- hare/fields/data/containers/nested_field.py +47 -0
- hare/fields/data/containers/tuple_field.py +177 -0
- hare/fields/data/json/__init__.py +7 -0
- hare/fields/data/json/json_codec.py +152 -0
- hare/fields/data/json/json_field.py +387 -0
- hare/fields/data/json/json_path_field.py +77 -0
- hare/fields/data/json/json_text_field.py +13 -0
- hare/fields/data/network/__init__.py +8 -0
- hare/fields/data/network/constants.py +6 -0
- hare/fields/data/network/ip_address_field.py +109 -0
- hare/fields/data/network/ipv4_address_field.py +26 -0
- hare/fields/data/numeric/__init__.py +23 -0
- hare/fields/data/numeric/big_int_field.py +22 -0
- hare/fields/data/numeric/decimal_field.py +187 -0
- hare/fields/data/numeric/float_field.py +83 -0
- hare/fields/data/numeric/int_field.py +239 -0
- hare/fields/data/numeric/positive_big_int_field.py +19 -0
- hare/fields/data/numeric/positive_int_field.py +19 -0
- hare/fields/data/numeric/positive_small_int_field.py +19 -0
- hare/fields/data/numeric/small_int_field.py +22 -0
- hare/fields/data/temporal/__init__.py +11 -0
- hare/fields/data/temporal/date_field.py +87 -0
- hare/fields/data/temporal/datetime_field.py +384 -0
- hare/fields/data/temporal/parse_datetime.py +17 -0
- hare/fields/data/temporal/temporal_values.py +119 -0
- hare/fields/data/temporal/time_delta_field.py +111 -0
- hare/fields/data/temporal/time_field.py +193 -0
- hare/fields/data/text/__init__.py +20 -0
- hare/fields/data/text/char_field.py +78 -0
- hare/fields/data/text/email_field.py +76 -0
- hare/fields/data/text/phone_field.py +114 -0
- hare/fields/data/text/slug_field.py +52 -0
- hare/fields/data/text/text_field.py +33 -0
- hare/fields/data/text/text_values.py +39 -0
- hare/fields/data/text/url_field.py +62 -0
- hare/fields/data/uuid_field.py +82 -0
- hare/fields/database_default.py +28 -0
- hare/fields/db_default_not_set.py +36 -0
- hare/fields/db_defaults/__init__.py +13 -0
- hare/fields/db_defaults/now.py +108 -0
- hare/fields/db_defaults/random_hex.py +30 -0
- hare/fields/db_defaults/sql_default.py +95 -0
- hare/fields/db_defaults/uuid_v7.py +36 -0
- hare/fields/encrypted/__init__.py +7 -0
- hare/fields/encrypted/blind_index_field.py +49 -0
- hare/fields/encrypted/constants.py +41 -0
- hare/fields/encrypted/encrypted_field_base.py +143 -0
- hare/fields/encrypted/encrypted_json_field.py +238 -0
- hare/fields/encrypted/encrypted_text_field.py +130 -0
- hare/fields/encrypted/field_encryption.py +267 -0
- hare/fields/enums.py +91 -0
- hare/fields/field.py +1231 -0
- hare/fields/field_meta.py +16 -0
- hare/fields/generated_field.py +211 -0
- hare/fields/narrowing/__init__.py +7 -0
- hare/fields/narrowing/decimal_digits_limit.py +11 -0
- hare/fields/narrowing/enum_values_limit.py +32 -0
- hare/fields/narrowing/integer_range_limit.py +13 -0
- hare/fields/narrowing/narrowing_limit.py +8 -0
- hare/fields/narrowing/text_length_limit.py +13 -0
- hare/fields/registrations/__init__.py +1 -0
- hare/fields/registrations/registered_lookup.py +29 -0
- hare/fields/registrations/registered_transform.py +22 -0
- hare/fields/relations/__init__.py +3 -0
- hare/fields/relations/constants.py +10 -0
- hare/fields/relations/declarations.py +5 -0
- hare/fields/relations/fields/__init__.py +35 -0
- hare/fields/relations/fields/backward_foreign_key_relation.py +46 -0
- hare/fields/relations/fields/declarations.py +21 -0
- hare/fields/relations/fields/foreign_key_field.py +89 -0
- hare/fields/relations/fields/foreign_key_field_instance.py +124 -0
- hare/fields/relations/fields/generic_foreign_key_field.py +56 -0
- hare/fields/relations/fields/generic_foreign_key_field_instance.py +455 -0
- hare/fields/relations/fields/many_to_many_field.py +60 -0
- hare/fields/relations/fields/many_to_many_field_instance.py +126 -0
- hare/fields/relations/fields/one_to_one_field.py +89 -0
- hare/fields/relations/fields/one_to_one_field_instance.py +45 -0
- hare/fields/relations/fields/relational_field.py +153 -0
- hare/fields/relations/inherited_relation.py +30 -0
- hare/fields/relations/relation_accessors.py +271 -0
- hare/fields/relations/relation_values.py +106 -0
- hare/fields/relations/swappable_model_reference.py +60 -0
- hare/fields/validators/__init__.py +63 -0
- hare/fields/validators/exceptions.py +52 -0
- hare/fields/validators/formats/__init__.py +1 -0
- hare/fields/validators/formats/comma_separated_integer_list_validator.py +22 -0
- hare/fields/validators/formats/domain_name_validator.py +74 -0
- hare/fields/validators/formats/e164_phone_validator.py +32 -0
- hare/fields/validators/formats/email_validator.py +87 -0
- hare/fields/validators/formats/ipv46_validator.py +28 -0
- hare/fields/validators/formats/ipv4_validator.py +23 -0
- hare/fields/validators/formats/ipv6_validator.py +23 -0
- hare/fields/validators/formats/regex_validator.py +38 -0
- hare/fields/validators/formats/slug_validator.py +36 -0
- hare/fields/validators/formats/url_validator.py +95 -0
- hare/fields/validators/limits/__init__.py +1 -0
- hare/fields/validators/limits/length_validator.py +17 -0
- hare/fields/validators/limits/max_digits_validator.py +58 -0
- hare/fields/validators/limits/max_length_validator.py +20 -0
- hare/fields/validators/limits/max_value_validator.py +19 -0
- hare/fields/validators/limits/min_length_validator.py +20 -0
- hare/fields/validators/limits/min_value_validator.py +19 -0
- hare/fields/validators/limits/numeric_validator.py +19 -0
- hare/fields/validators/validator.py +34 -0
- hare/gis/__init__.py +52 -0
- hare/gis/aggregates/__init__.py +5 -0
- hare/gis/aggregates/declarations.py +42 -0
- hare/gis/aggregates/spatial_aggregate.py +57 -0
- hare/gis/constants.py +126 -0
- hare/gis/enums.py +74 -0
- hare/gis/fields/__init__.py +23 -0
- hare/gis/fields/declarations.py +61 -0
- hare/gis/fields/extent_field.py +60 -0
- hare/gis/fields/geometry_field.py +239 -0
- hare/gis/fields/made_line_field.py +86 -0
- hare/gis/functions/__init__.py +53 -0
- hare/gis/functions/buffer.py +29 -0
- hare/gis/functions/constants.py +17 -0
- hare/gis/functions/declarations.py +188 -0
- hare/gis/functions/simplify.py +29 -0
- hare/gis/functions/spatial_function.py +115 -0
- hare/gis/functions/transform.py +41 -0
- hare/gis/geometries/__init__.py +19 -0
- hare/gis/geometries/declarations.py +38 -0
- hare/gis/geometries/geometry.py +297 -0
- hare/gis/geometries/geometry_collection.py +62 -0
- hare/gis/geometries/line_string.py +46 -0
- hare/gis/geometries/multi_geometry.py +75 -0
- hare/gis/geometries/point.py +65 -0
- hare/gis/geometries/polygon.py +89 -0
- hare/gis/lookups/__init__.py +3 -0
- hare/gis/lookups/spatial_field_lookups.py +219 -0
- hare/gis/readers/__init__.py +11 -0
- hare/gis/readers/constants.py +15 -0
- hare/gis/readers/ewkb_reader.py +148 -0
- hare/gis/readers/geo_json_reader.py +54 -0
- hare/gis/readers/wkt_reader.py +226 -0
- hare/gis/spatial_features.py +57 -0
- hare/gis/terms/__init__.py +11 -0
- hare/gis/terms/geometry_value.py +33 -0
- hare/gis/terms/spatial_aggregate_function.py +30 -0
- hare/gis/terms/spatial_function_term.py +39 -0
- hare/gis/terms/spatial_relation_term.py +39 -0
- hare/health/__init__.py +19 -0
- hare/health/constants.py +32 -0
- hare/health/criteria/__init__.py +27 -0
- hare/health/criteria/acquire_wait_time.py +35 -0
- hare/health/criteria/all_of.py +38 -0
- hare/health/criteria/declarations.py +33 -0
- hare/health/criteria/health_criterion.py +87 -0
- hare/health/criteria/ping_failed.py +27 -0
- hare/health/criteria/ping_latency.py +29 -0
- hare/health/criteria/pool_count_criterion.py +37 -0
- hare/health/criteria/pool_saturation.py +35 -0
- hare/health/criteria/waiting_requests.py +33 -0
- hare/health/declarations.py +83 -0
- hare/health/enums.py +14 -0
- hare/health/health_check.py +240 -0
- hare/health/health_report.py +65 -0
- hare/inspectdb/__init__.py +38 -0
- hare/inspectdb/constants.py +60 -0
- hare/inspectdb/exceptions.py +72 -0
- hare/inspectdb/generation/__init__.py +1 -0
- hare/inspectdb/generation/column_type_mapper.py +113 -0
- hare/inspectdb/generation/declarations.py +34 -0
- hare/inspectdb/generation/inspected_model.py +35 -0
- hare/inspectdb/generation/inspected_model_builder.py +1174 -0
- hare/inspectdb/generation/many_to_many_tables.py +91 -0
- hare/inspectdb/generation/model_factory.py +88 -0
- hare/inspectdb/generation/model_naming.py +75 -0
- hare/inspectdb/generation/model_source_builder.py +148 -0
- hare/inspectdb/introspection/__init__.py +28 -0
- hare/inspectdb/introspection/column_info.py +67 -0
- hare/inspectdb/introspection/composite_foreign_key_info.py +27 -0
- hare/inspectdb/introspection/database_catalog.py +252 -0
- hare/inspectdb/introspection/enums.py +26 -0
- hare/inspectdb/introspection/foreign_key_info.py +25 -0
- hare/inspectdb/introspection/index_info.py +265 -0
- hare/inspectdb/introspection/inspected_field_specification.py +47 -0
- hare/inspectdb/introspection/schema_introspector.py +564 -0
- hare/inspectdb/introspection/schema_part.py +103 -0
- hare/inspectdb/introspection/table_info.py +112 -0
- hare/inspectdb/introspection/table_parts.py +101 -0
- hare/inspectdb/schema_inspector.py +224 -0
- hare/instrumentation/__init__.py +31 -0
- hare/instrumentation/capture/__init__.py +9 -0
- hare/instrumentation/capture/capture_needs.py +54 -0
- hare/instrumentation/capture/captured_change.py +38 -0
- hare/instrumentation/capture/captured_write.py +223 -0
- hare/instrumentation/capture/change_capturing.py +496 -0
- hare/instrumentation/capture/change_sink.py +57 -0
- hare/instrumentation/change_events.py +246 -0
- hare/instrumentation/constants.py +41 -0
- hare/instrumentation/declarations.py +196 -0
- hare/instrumentation/enums.py +35 -0
- hare/instrumentation/observers/__init__.py +1 -0
- hare/instrumentation/observers/observer.py +56 -0
- hare/instrumentation/observers/observer_dispatch.py +197 -0
- hare/instrumentation/observers/observer_set.py +138 -0
- hare/instrumentation/observers/observers.py +368 -0
- hare/instrumentation/pools/__init__.py +1 -0
- hare/instrumentation/pools/duration_records.py +50 -0
- hare/instrumentation/pools/pool_metrics.py +50 -0
- hare/instrumentation/pools/pool_registry.py +49 -0
- hare/instrumentation/queries/__init__.py +1 -0
- hare/instrumentation/queries/query_tags.py +133 -0
- hare/instrumentation/queries/query_wrapper.py +37 -0
- hare/lazy_loading/__init__.py +1 -0
- hare/lazy_loading/lazy_pattern.py +45 -0
- hare/lazy_loading/pydantic_classes.py +96 -0
- hare/migrations/__init__.py +90 -0
- hare/migrations/api/__init__.py +24 -0
- hare/migrations/api/checkmigrations.py +55 -0
- hare/migrations/api/makemigrations.py +78 -0
- hare/migrations/api/migrate.py +47 -0
- hare/migrations/api/migration_request_parser.py +86 -0
- hare/migrations/api/plan.py +39 -0
- hare/migrations/api/sqlmigrate.py +51 -0
- hare/migrations/api/squashmigrations.py +51 -0
- hare/migrations/autodetection/__init__.py +4 -0
- hare/migrations/autodetection/constants.py +49 -0
- hare/migrations/autodetection/diffs/__init__.py +1 -0
- hare/migrations/autodetection/diffs/constraint_diff.py +48 -0
- hare/migrations/autodetection/diffs/declarations.py +73 -0
- hare/migrations/autodetection/diffs/declared_schema_object_diff.py +47 -0
- hare/migrations/autodetection/diffs/grant_diff.py +24 -0
- hare/migrations/autodetection/diffs/index_diff.py +73 -0
- hare/migrations/autodetection/diffs/materialized_view_diff.py +44 -0
- hare/migrations/autodetection/diffs/partition_diff.py +99 -0
- hare/migrations/autodetection/diffs/schema_object_diff.py +153 -0
- hare/migrations/autodetection/diffs/state_field_diff.py +566 -0
- hare/migrations/autodetection/diffs/state_model_diff.py +355 -0
- hare/migrations/autodetection/diffs/trigger_diff.py +31 -0
- hare/migrations/autodetection/diffs/view_diff.py +24 -0
- hare/migrations/autodetection/field_comparable_values.py +20 -0
- hare/migrations/autodetection/migration_autodetector.py +337 -0
- hare/migrations/autodetection/migration_splitter.py +151 -0
- hare/migrations/autodetection/operation_generator.py +1115 -0
- hare/migrations/autodetection/operation_sorter.py +213 -0
- hare/migrations/autodetection/rename_questions.py +98 -0
- hare/migrations/autodetection/required_extensions.py +118 -0
- hare/migrations/autodetection/schema_object_operations.py +150 -0
- hare/migrations/autodetection/split_migration.py +24 -0
- hare/migrations/autodetection/state_signatures.py +192 -0
- hare/migrations/constants.py +109 -0
- hare/migrations/drift/__init__.py +13 -0
- hare/migrations/drift/column_mismatch.py +14 -0
- hare/migrations/drift/constants.py +43 -0
- hare/migrations/drift/detect_drift.py +40 -0
- hare/migrations/drift/detect_drift_for_alias.py +87 -0
- hare/migrations/drift/drift_result.py +22 -0
- hare/migrations/drift/shadow/__init__.py +0 -0
- hare/migrations/drift/shadow/column_field_names.py +26 -0
- hare/migrations/drift/shadow/schema_comparison.py +557 -0
- hare/migrations/drift/shadow/shadow_drift.py +318 -0
- hare/migrations/drift/shadow/shadow_state.py +83 -0
- hare/migrations/exceptions.py +69 -0
- hare/migrations/execution/__init__.py +3 -0
- hare/migrations/execution/connections_plan.py +192 -0
- hare/migrations/execution/constants.py +4 -0
- hare/migrations/execution/executor/__init__.py +11 -0
- hare/migrations/execution/executor/migration_executor.py +640 -0
- hare/migrations/execution/executor/migration_target.py +9 -0
- hare/migrations/execution/executor/plan_step.py +30 -0
- hare/migrations/execution/migration_runner.py +304 -0
- hare/migrations/execution/swappable_setting_check.py +161 -0
- hare/migrations/loading/__init__.py +4 -0
- hare/migrations/loading/graph/__init__.py +13 -0
- hare/migrations/loading/graph/dummy_node.py +22 -0
- hare/migrations/loading/graph/migration_graph.py +235 -0
- hare/migrations/loading/graph/migration_key.py +14 -0
- hare/migrations/loading/graph/node.py +40 -0
- hare/migrations/loading/migration_loader.py +256 -0
- hare/migrations/loading/migrations_modules.py +207 -0
- hare/migrations/loading/recorder/__init__.py +9 -0
- hare/migrations/loading/recorder/migration_recorder.py +130 -0
- hare/migrations/loading/recorder/noop_recorder.py +26 -0
- hare/migrations/making/__init__.py +1 -0
- hare/migrations/making/declared_attribute_values.py +27 -0
- hare/migrations/making/migration_changes.py +27 -0
- hare/migrations/making/migration_checks.py +115 -0
- hare/migrations/making/migration_maker.py +291 -0
- hare/migrations/making/migration_optimizer.py +70 -0
- hare/migrations/making/migration_squasher.py +193 -0
- hare/migrations/making/squashed_migration.py +24 -0
- hare/migrations/migration.py +341 -0
- hare/migrations/operations/__init__.py +132 -0
- hare/migrations/operations/columns/__init__.py +11 -0
- hare/migrations/operations/columns/alter_column_not_null_safe.py +140 -0
- hare/migrations/operations/columns/backfill_column.py +118 -0
- hare/migrations/operations/constants.py +20 -0
- hare/migrations/operations/constraints/__init__.py +15 -0
- hare/migrations/operations/constraints/add_constraint.py +129 -0
- hare/migrations/operations/constraints/declarations.py +13 -0
- hare/migrations/operations/constraints/rename_constraint.py +21 -0
- hare/migrations/operations/constraints/validate_constraint.py +66 -0
- hare/migrations/operations/database_functions/__init__.py +10 -0
- hare/migrations/operations/database_functions/add_function.py +28 -0
- hare/migrations/operations/database_functions/alter_function.py +30 -0
- hare/migrations/operations/database_functions/remove_function.py +20 -0
- hare/migrations/operations/database_functions/rename_function.py +21 -0
- hare/migrations/operations/declared_uniqueness_checks.py +76 -0
- hare/migrations/operations/dependencies/__init__.py +1 -0
- hare/migrations/operations/dependencies/operation_dependency.py +89 -0
- hare/migrations/operations/dependencies/relation_dependencies.py +157 -0
- hare/migrations/operations/dictionaries/__init__.py +10 -0
- hare/migrations/operations/dictionaries/add_dictionary.py +28 -0
- hare/migrations/operations/dictionaries/alter_dictionary.py +29 -0
- hare/migrations/operations/dictionaries/remove_dictionary.py +20 -0
- hare/migrations/operations/dictionaries/rename_dictionary.py +21 -0
- hare/migrations/operations/enum_types/__init__.py +7 -0
- hare/migrations/operations/enum_types/alter_enum_type.py +64 -0
- hare/migrations/operations/enum_types/create_enum_type.py +57 -0
- hare/migrations/operations/enum_types/drop_enum_type.py +66 -0
- hare/migrations/operations/enum_types/enum_type_operation.py +35 -0
- hare/migrations/operations/enums.py +24 -0
- hare/migrations/operations/extensions/__init__.py +15 -0
- hare/migrations/operations/extensions/create_collation.py +82 -0
- hare/migrations/operations/extensions/create_extension.py +47 -0
- hare/migrations/operations/extensions/remove_collation.py +35 -0
- hare/migrations/operations/extensions/remove_extension.py +40 -0
- hare/migrations/operations/fields/__init__.py +11 -0
- hare/migrations/operations/fields/add_field.py +135 -0
- hare/migrations/operations/fields/alter_field.py +128 -0
- hare/migrations/operations/fields/field_add_remove_operation.py +41 -0
- hare/migrations/operations/fields/field_like.py +14 -0
- hare/migrations/operations/fields/remove_field.py +326 -0
- hare/migrations/operations/fields/rename_field.py +725 -0
- hare/migrations/operations/grants/__init__.py +8 -0
- hare/migrations/operations/grants/add_grant.py +31 -0
- hare/migrations/operations/grants/remove_grant.py +35 -0
- hare/migrations/operations/hare_operation.py +174 -0
- hare/migrations/operations/indexes/__init__.py +13 -0
- hare/migrations/operations/indexes/add_index.py +42 -0
- hare/migrations/operations/indexes/declarations.py +12 -0
- hare/migrations/operations/indexes/remove_index.py +36 -0
- hare/migrations/operations/materialized_views/__init__.py +17 -0
- hare/migrations/operations/materialized_views/add_materialized_view.py +37 -0
- hare/migrations/operations/materialized_views/alter_materialized_view.py +32 -0
- hare/migrations/operations/materialized_views/refresh_materialized_view.py +57 -0
- hare/migrations/operations/materialized_views/remove_materialized_view.py +28 -0
- hare/migrations/operations/materialized_views/rename_materialized_view.py +23 -0
- hare/migrations/operations/model_bound_operation.py +95 -0
- hare/migrations/operations/models/__init__.py +12 -0
- hare/migrations/operations/models/alter_model_options.py +158 -0
- hare/migrations/operations/models/alter_model_schema.py +114 -0
- hare/migrations/operations/models/alter_model_table.py +65 -0
- hare/migrations/operations/models/create_model.py +407 -0
- hare/migrations/operations/models/delete_model.py +122 -0
- hare/migrations/operations/models/model_table_operation.py +45 -0
- hare/migrations/operations/models/rename_model.py +165 -0
- hare/migrations/operations/models/table_renaming_operation.py +101 -0
- hare/migrations/operations/operation.py +252 -0
- hare/migrations/operations/partitions/__init__.py +11 -0
- hare/migrations/operations/partitions/add_partition.py +36 -0
- hare/migrations/operations/partitions/partition_operation.py +93 -0
- hare/migrations/operations/partitions/remove_partition.py +36 -0
- hare/migrations/operations/policies/__init__.py +11 -0
- hare/migrations/operations/policies/add_policy.py +28 -0
- hare/migrations/operations/policies/alter_policy.py +30 -0
- hare/migrations/operations/policies/alter_row_level_security.py +90 -0
- hare/migrations/operations/policies/remove_policy.py +21 -0
- hare/migrations/operations/policies/rename_policy.py +21 -0
- hare/migrations/operations/schema_objects/__init__.py +11 -0
- hare/migrations/operations/schema_objects/add_schema_object.py +103 -0
- hare/migrations/operations/schema_objects/alter_schema_object.py +89 -0
- hare/migrations/operations/schema_objects/object_types/__init__.py +1 -0
- hare/migrations/operations/schema_objects/object_types/constraint_object_type.py +98 -0
- hare/migrations/operations/schema_objects/object_types/dictionary_object_type.py +51 -0
- hare/migrations/operations/schema_objects/object_types/function_object_type.py +55 -0
- hare/migrations/operations/schema_objects/object_types/grant_object_type.py +71 -0
- hare/migrations/operations/schema_objects/object_types/index_object_type.py +140 -0
- hare/migrations/operations/schema_objects/object_types/materialized_view_object_type.py +63 -0
- hare/migrations/operations/schema_objects/object_types/policy_object_type.py +53 -0
- hare/migrations/operations/schema_objects/object_types/schema_object_type.py +234 -0
- hare/migrations/operations/schema_objects/object_types/sequence_object_type.py +54 -0
- hare/migrations/operations/schema_objects/object_types/trigger_object_type.py +46 -0
- hare/migrations/operations/schema_objects/object_types/view_object_type.py +60 -0
- hare/migrations/operations/schema_objects/remove_schema_object.py +105 -0
- hare/migrations/operations/schema_objects/rename_schema_object.py +116 -0
- hare/migrations/operations/schemas/__init__.py +11 -0
- hare/migrations/operations/schemas/create_schema.py +45 -0
- hare/migrations/operations/schemas/drop_schema.py +40 -0
- hare/migrations/operations/sequences/__init__.py +10 -0
- hare/migrations/operations/sequences/add_sequence.py +28 -0
- hare/migrations/operations/sequences/alter_sequence.py +29 -0
- hare/migrations/operations/sequences/remove_sequence.py +20 -0
- hare/migrations/operations/sequences/rename_sequence.py +21 -0
- hare/migrations/operations/special/__init__.py +16 -0
- hare/migrations/operations/special/run_python.py +82 -0
- hare/migrations/operations/special/run_sql.py +107 -0
- hare/migrations/operations/special/separate_database_and_state.py +95 -0
- hare/migrations/operations/special/synchronize_key_series.py +51 -0
- hare/migrations/operations/triggers/__init__.py +15 -0
- hare/migrations/operations/triggers/add_trigger.py +28 -0
- hare/migrations/operations/triggers/alter_trigger.py +28 -0
- hare/migrations/operations/triggers/remove_trigger.py +20 -0
- hare/migrations/operations/triggers/rename_trigger.py +21 -0
- hare/migrations/operations/views/__init__.py +10 -0
- hare/migrations/operations/views/add_view.py +29 -0
- hare/migrations/operations/views/alter_view.py +29 -0
- hare/migrations/operations/views/remove_view.py +20 -0
- hare/migrations/operations/views/rename_view.py +21 -0
- hare/migrations/reports/__init__.py +12 -0
- hare/migrations/reports/operation_effect.py +28 -0
- hare/migrations/reports/operation_plan.py +23 -0
- hare/migrations/runtime_enums.py +88 -0
- hare/migrations/safety/__init__.py +16 -0
- hare/migrations/safety/enums.py +37 -0
- hare/migrations/safety/migration_risk.py +33 -0
- hare/migrations/safety/migration_safety_checker.py +250 -0
- hare/migrations/safety/migration_safety_context.py +142 -0
- hare/migrations/state/__init__.py +11 -0
- hare/migrations/state/model_state.py +359 -0
- hare/migrations/state/state.py +297 -0
- hare/migrations/state/state_apps.py +315 -0
- hare/migrations/state/state_rendering.py +222 -0
- hare/migrations/swappable_dependency.py +36 -0
- hare/migrations/writer/__init__.py +9 -0
- hare/migrations/writer/constants.py +28 -0
- hare/migrations/writer/import_manager.py +106 -0
- hare/migrations/writer/migration_writer.py +986 -0
- hare/models/__init__.py +20 -0
- hare/models/class_building/__init__.py +1 -0
- hare/models/class_building/abstract_meta_inheritance.py +116 -0
- hare/models/class_building/blind_indexes.py +54 -0
- hare/models/class_building/constants.py +61 -0
- hare/models/class_building/extension_model_options.py +20 -0
- hare/models/class_building/field_comments.py +131 -0
- hare/models/class_building/generic_foreign_keys.py +287 -0
- hare/models/class_building/instance_constructors.py +110 -0
- hare/models/class_building/lazy_relation_fields.py +140 -0
- hare/models/class_building/model_definition_checks.py +710 -0
- hare/models/class_building/model_field_collection.py +185 -0
- hare/models/class_building/model_managers.py +62 -0
- hare/models/class_building/primary_key_declaration.py +204 -0
- hare/models/class_building/schema_object_declarations.py +106 -0
- hare/models/constants.py +75 -0
- hare/models/deletion/__init__.py +0 -0
- hare/models/deletion/cascade/__init__.py +1 -0
- hare/models/deletion/cascade/cascade_deletion.py +818 -0
- hare/models/deletion/cascade/cascade_restore.py +150 -0
- hare/models/deletion/cascade/deletion_collector.py +646 -0
- hare/models/deletion/cascade/deletion_graph.py +418 -0
- hare/models/deletion/cascade/deletion_plan.py +94 -0
- hare/models/deletion/cascade/protect_constraint_deferral.py +91 -0
- hare/models/deletion/cascade/related_rows.py +417 -0
- hare/models/deletion/cascade/tenant_schema_visits.py +96 -0
- hare/models/deletion/constants.py +29 -0
- hare/models/deletion/instance_deletion.py +288 -0
- hare/models/deletion/preview/__init__.py +1 -0
- hare/models/deletion/preview/delete_preview.py +93 -0
- hare/models/deletion/preview/delete_preview_builder.py +431 -0
- hare/models/deletion/soft_deletion.py +207 -0
- hare/models/enums.py +76 -0
- hare/models/instances/__init__.py +1 -0
- hare/models/instances/dirty_fields.py +99 -0
- hare/models/instances/field_snapshot.py +116 -0
- hare/models/instances/instance_connections.py +61 -0
- hare/models/instances/instance_copies.py +46 -0
- hare/models/instances/instance_initialization.py +323 -0
- hare/models/instances/instance_refresh.py +158 -0
- hare/models/instances/instance_saving.py +512 -0
- hare/models/meta_info.py +1143 -0
- hare/models/model.py +935 -0
- hare/models/model_meta.py +255 -0
- hare/models/tenancy/__init__.py +1 -0
- hare/models/tenancy/constants.py +16 -0
- hare/models/tenancy/tenancy.py +363 -0
- hare/models/tenancy/tenant_row_level_security.py +76 -0
- hare/models/tenancy/tenant_schemas.py +232 -0
- hare/models/uniqueness/__init__.py +0 -0
- hare/models/uniqueness/declared_uniqueness.py +99 -0
- hare/models/write/__init__.py +3 -0
- hare/models/write/generated_keys.py +97 -0
- hare/models/write/insert/__init__.py +1 -0
- hare/models/write/insert/insert_conflict.py +88 -0
- hare/models/write/insert/insert_statement.py +155 -0
- hare/models/write/instance_capture.py +173 -0
- hare/models/write/instance_values.py +126 -0
- hare/models/write/instance_writer.py +949 -0
- hare/models/write/returned_values.py +98 -0
- hare/models/write/rollback_restores.py +213 -0
- hare/models/write/rules/__init__.py +2 -0
- hare/models/write/rules/constants.py +65 -0
- hare/models/write/rules/enums.py +18 -0
- hare/models/write/rules/relation_key_values.py +50 -0
- hare/models/write/rules/row_write_rules.py +635 -0
- hare/models/write/rules/tenant_write_rules.py +300 -0
- hare/models/write/rules/written_instances.py +37 -0
- hare/models/write/rules/written_target_checks.py +63 -0
- hare/models/write/update/__init__.py +1 -0
- hare/models/write/update/expression_assignment.py +162 -0
- hare/models/write/update/update_parameter_slot.py +43 -0
- hare/models/write/write_steps.py +98 -0
- hare/native/__init__.py +1 -0
- hare/native/native_modules.py +19 -0
- hare/numbers/__init__.py +1 -0
- hare/numbers/finite_numbers.py +27 -0
- hare/py.typed +0 -0
- hare/query/__init__.py +0 -0
- hare/query/constants.py +41 -0
- hare/query/enums.py +129 -0
- hare/query/expressions/__init__.py +63 -0
- hare/query/expressions/aggregate.py +442 -0
- hare/query/expressions/aggregate_paths/__init__.py +9 -0
- hare/query/expressions/aggregate_paths/aggregate_crossing.py +20 -0
- hare/query/expressions/aggregate_paths/aggregated_multi_valued_paths.py +581 -0
- hare/query/expressions/aggregate_paths/constants.py +10 -0
- hare/query/expressions/arithmetic/__init__.py +1 -0
- hare/query/expressions/arithmetic/arithmetic_operators.py +57 -0
- hare/query/expressions/arithmetic/combinable_expression.py +47 -0
- hare/query/expressions/arithmetic/combined_expression.py +614 -0
- hare/query/expressions/arithmetic/constants.py +37 -0
- hare/query/expressions/case/__init__.py +1 -0
- hare/query/expressions/case/case.py +230 -0
- hare/query/expressions/case/case_branch_value.py +14 -0
- hare/query/expressions/case/when.py +167 -0
- hare/query/expressions/compatibility/__init__.py +9 -0
- hare/query/expressions/compatibility/constants.py +107 -0
- hare/query/expressions/compatibility/output_field_compatibility.py +248 -0
- hare/query/expressions/compatibility/result_branch.py +46 -0
- hare/query/expressions/conditions/__init__.py +1 -0
- hare/query/expressions/conditions/q.py +525 -0
- hare/query/expressions/conditions/query_modifier.py +90 -0
- hare/query/expressions/constants.py +120 -0
- hare/query/expressions/declarations.py +12 -0
- hare/query/expressions/enums.py +39 -0
- hare/query/expressions/expression.py +129 -0
- hare/query/expressions/expression_context.py +63 -0
- hare/query/expressions/expression_result.py +41 -0
- hare/query/expressions/f.py +212 -0
- hare/query/expressions/frames/__init__.py +12 -0
- hare/query/expressions/frames/constants.py +14 -0
- hare/query/expressions/frames/declarations.py +22 -0
- hare/query/expressions/frames/window_frame.py +126 -0
- hare/query/expressions/function.py +490 -0
- hare/query/expressions/joins/__init__.py +1 -0
- hare/query/expressions/joins/array_join.py +147 -0
- hare/query/expressions/joins/array_join_element.py +27 -0
- hare/query/expressions/joins/asof_join.py +263 -0
- hare/query/expressions/joins/filtered_relation.py +338 -0
- hare/query/expressions/joins/json_table.py +147 -0
- hare/query/expressions/joins/json_table_column.py +21 -0
- hare/query/expressions/joins/lateral.py +88 -0
- hare/query/expressions/joins/merge_source_row.py +44 -0
- hare/query/expressions/joins/named_columns.py +43 -0
- hare/query/expressions/joins/named_join.py +204 -0
- hare/query/expressions/numeric/__init__.py +11 -0
- hare/query/expressions/numeric/numeric_type.py +18 -0
- hare/query/expressions/numeric/numeric_typing.py +216 -0
- hare/query/expressions/numeric/unrounded_decimal_field.py +16 -0
- hare/query/expressions/ordering.py +55 -0
- hare/query/expressions/raw_sql.py +168 -0
- hare/query/expressions/subqueries/__init__.py +1 -0
- hare/query/expressions/subqueries/cte_rows.py +46 -0
- hare/query/expressions/subqueries/declarations.py +8 -0
- hare/query/expressions/subqueries/exists.py +181 -0
- hare/query/expressions/subqueries/outer_reference.py +157 -0
- hare/query/expressions/subqueries/outer_scope.py +74 -0
- hare/query/expressions/subqueries/recursive_rows.py +177 -0
- hare/query/expressions/subqueries/subquery.py +236 -0
- hare/query/expressions/temporal/__init__.py +9 -0
- hare/query/expressions/temporal/constants.py +43 -0
- hare/query/expressions/temporal/temporal_arithmetic.py +254 -0
- hare/query/expressions/temporal/temporal_operand.py +25 -0
- hare/query/expressions/term_expression.py +28 -0
- hare/query/expressions/value.py +259 -0
- hare/query/expressions/value_references/__init__.py +49 -0
- hare/query/expressions/value_references/array_value_reference.py +41 -0
- hare/query/expressions/value_references/composite_key_value_reference.py +61 -0
- hare/query/expressions/value_references/cursor_value_reference.py +41 -0
- hare/query/expressions/value_references/encoded_value_reference.py +43 -0
- hare/query/expressions/value_references/expression_arguments.py +181 -0
- hare/query/expressions/value_references/like_value_reference.py +46 -0
- hare/query/expressions/value_references/list_parameter_value_reference.py +65 -0
- hare/query/expressions/value_references/list_value_reference.py +55 -0
- hare/query/expressions/value_references/literal_value_reference.py +38 -0
- hare/query/expressions/value_references/open_range_value_reference.py +53 -0
- hare/query/expressions/value_references/range_value_reference.py +49 -0
- hare/query/expressions/value_references/rebuilt_criterion_value_reference.py +93 -0
- hare/query/expressions/value_references/related_key_value_reference.py +67 -0
- hare/query/expressions/value_references/related_value_reference.py +33 -0
- hare/query/expressions/value_references/row_list_value_reference.py +67 -0
- hare/query/expressions/value_references/scalar_value_reference.py +41 -0
- hare/query/expressions/value_references/value_reference_types.py +65 -0
- hare/query/expressions/value_references/write_value_reference.py +41 -0
- hare/query/expressions/window.py +220 -0
- hare/query/filters/__init__.py +21 -0
- hare/query/filters/constants.py +89 -0
- hare/query/filters/lookups/__init__.py +1 -0
- hare/query/filters/lookups/annotation_container_lookups.py +40 -0
- hare/query/filters/lookups/constants.py +60 -0
- hare/query/filters/lookups/containers/__init__.py +3 -0
- hare/query/filters/lookups/containers/container_field_lookups.py +78 -0
- hare/query/filters/lookups/containers/container_lookups.py +80 -0
- hare/query/filters/lookups/containers/container_value_encoders.py +94 -0
- hare/query/filters/lookups/date_part_lookups.py +292 -0
- hare/query/filters/lookups/dialect_implemented_operators.py +39 -0
- hare/query/filters/lookups/field_lookup.py +59 -0
- hare/query/filters/lookups/field_lookups.py +289 -0
- hare/query/filters/lookups/field_transforms.py +98 -0
- hare/query/filters/lookups/json/__init__.py +1 -0
- hare/query/filters/lookups/json/json_filter_guards.py +412 -0
- hare/query/filters/lookups/json/json_filter_parser.py +82 -0
- hare/query/filters/lookups/json/json_lookups.py +67 -0
- hare/query/filters/lookups/json/json_path_lookups.py +184 -0
- hare/query/filters/lookups/lookups.py +371 -0
- hare/query/filters/lookups/value_encoders.py +246 -0
- hare/query/filters/resolution/__init__.py +1 -0
- hare/query/filters/resolution/annotation_filters.py +280 -0
- hare/query/filters/resolution/composite_key_filters.py +439 -0
- hare/query/filters/resolution/filter_kwargs.py +704 -0
- hare/query/filters/resolution/filter_values.py +565 -0
- hare/query/filters/resolution/json_path_filters.py +157 -0
- hare/query/filters/resolution/lookup_support.py +84 -0
- hare/query/filters/resolution/relation_filters.py +510 -0
- hare/query/filters/resolution/sensitive_filter_keys.py +91 -0
- hare/query/filters/resolution/to_many_filters.py +436 -0
- hare/query/functions/__init__.py +185 -0
- hare/query/functions/aggregates/__init__.py +9 -0
- hare/query/functions/aggregates/array_agg.py +48 -0
- hare/query/functions/aggregates/avg.py +59 -0
- hare/query/functions/aggregates/constants.py +5 -0
- hare/query/functions/aggregates/count.py +81 -0
- hare/query/functions/aggregates/declarations.py +51 -0
- hare/query/functions/aggregates/statistic_aggregate.py +67 -0
- hare/query/functions/aggregates/sum.py +55 -0
- hare/query/functions/comparison/__init__.py +9 -0
- hare/query/functions/comparison/cast.py +121 -0
- hare/query/functions/comparison/coalesce.py +140 -0
- hare/query/functions/comparison/collate.py +45 -0
- hare/query/functions/comparison/declarations.py +21 -0
- hare/query/functions/comparison/function_arguments.py +70 -0
- hare/query/functions/comparison/greatest_least_function.py +108 -0
- hare/query/functions/comparison/null_if.py +78 -0
- hare/query/functions/containers/__init__.py +7 -0
- hare/query/functions/containers/array_item.py +69 -0
- hare/query/functions/datetime/__init__.py +55 -0
- hare/query/functions/datetime/date_function_source.py +31 -0
- hare/query/functions/datetime/declarations.py +193 -0
- hare/query/functions/datetime/extract.py +97 -0
- hare/query/functions/datetime/now.py +26 -0
- hare/query/functions/datetime/trunc.py +124 -0
- hare/query/functions/json/__init__.py +6 -0
- hare/query/functions/json/json_array.py +34 -0
- hare/query/functions/json/json_object.py +161 -0
- hare/query/functions/math/__init__.py +53 -0
- hare/query/functions/math/declarations.py +192 -0
- hare/query/functions/math/enums.py +16 -0
- hare/query/functions/math/math_function.py +110 -0
- hare/query/functions/math/mod.py +52 -0
- hare/query/functions/math/pi.py +21 -0
- hare/query/functions/math/random.py +22 -0
- hare/query/functions/math/round.py +85 -0
- hare/query/functions/text/__init__.py +55 -0
- hare/query/functions/text/concat.py +99 -0
- hare/query/functions/text/declarations.py +197 -0
- hare/query/functions/text/l_pad.py +17 -0
- hare/query/functions/text/length.py +38 -0
- hare/query/functions/text/r_pad.py +17 -0
- hare/query/functions/text/replace.py +17 -0
- hare/query/functions/text/text_function.py +114 -0
- hare/query/functions/window/__init__.py +45 -0
- hare/query/functions/window/aggregate_window_function.py +43 -0
- hare/query/functions/window/avg.py +23 -0
- hare/query/functions/window/constants.py +3 -0
- hare/query/functions/window/count.py +54 -0
- hare/query/functions/window/declarations.py +153 -0
- hare/query/functions/window/distribution_window_function.py +21 -0
- hare/query/functions/window/field_window_function.py +149 -0
- hare/query/functions/window/n_tile.py +41 -0
- hare/query/functions/window/nth_value.py +54 -0
- hare/query/functions/window/offset_window_function.py +85 -0
- hare/query/functions/window/rank_like_window_function.py +21 -0
- hare/query/functions/window/statistic_window_function.py +44 -0
- hare/query/functions/window/sum.py +23 -0
- hare/query/functions/window/window_function.py +134 -0
- hare/query/generic_foreign_keys/__init__.py +3 -0
- hare/query/generic_foreign_keys/constants.py +21 -0
- hare/query/generic_foreign_keys/generic_foreign_key_filters.py +251 -0
- hare/query/generic_foreign_keys/generic_foreign_key_paths.py +183 -0
- hare/query/generic_foreign_keys/generic_foreign_key_types.py +94 -0
- hare/query/grouping/__init__.py +14 -0
- hare/query/grouping/declarations.py +21 -0
- hare/query/grouping/grouping.py +60 -0
- hare/query/grouping/grouping_set.py +67 -0
- hare/query/grouping/grouping_sets.py +55 -0
- hare/query/key_columns.py +297 -0
- hare/query/lookup_info/__init__.py +12 -0
- hare/query/lookup_info/declarations.py +27 -0
- hare/query/lookup_info/lookup_info.py +89 -0
- hare/query/lookup_info/lookup_info_builder.py +807 -0
- hare/query/lookup_info/lookup_path.py +94 -0
- hare/query/lookup_info/lookup_paths.py +415 -0
- hare/query/lookup_info/ordering_info.py +43 -0
- hare/query/lookup_info/value_paths.py +135 -0
- hare/query/managers/__init__.py +1 -0
- hare/query/managers/base_manager.py +20 -0
- hare/query/managers/manager.py +130 -0
- hare/query/plans/__init__.py +4 -0
- hare/query/plans/call_signatures/__init__.py +1 -0
- hare/query/plans/call_signatures/call_signature_plans.py +318 -0
- hare/query/plans/call_signatures/call_signature_runs.py +466 -0
- hare/query/plans/constants.py +37 -0
- hare/query/plans/description/__init__.py +11 -0
- hare/query/plans/description/declared_plan_parts.py +7 -0
- hare/query/plans/description/filter_plan_descriptions.py +229 -0
- hare/query/plans/description/hashable_values.py +22 -0
- hare/query/plans/description/plan_context.py +33 -0
- hare/query/plans/description/plan_describer_compiler.py +355 -0
- hare/query/plans/description/plan_description.py +66 -0
- hare/query/plans/description/plan_parts.py +150 -0
- hare/query/plans/description/plannable.py +69 -0
- hare/query/plans/description/term_plan_descriptions.py +92 -0
- hare/query/plans/enums.py +97 -0
- hare/query/plans/plan_origins.py +99 -0
- hare/query/plans/recording/__init__.py +1 -0
- hare/query/plans/recording/plan_recording.py +100 -0
- hare/query/plans/recording/scope_value_source.py +67 -0
- hare/query/plans/statement/__init__.py +1 -0
- hare/query/plans/statement/declared_plan_slots.py +11 -0
- hare/query/plans/statement/query_key_compiler.py +171 -0
- hare/query/plans/statement/raw_sql_plan.py +47 -0
- hare/query/plans/statement/statement_plan.py +522 -0
- hare/query/plans/statement/statement_plan_descriptions.py +451 -0
- hare/query/plans/statement/statement_plan_runs.py +306 -0
- hare/query/plans/statement/statement_plans.py +128 -0
- hare/query/query_connection.py +110 -0
- hare/query/queryset/__init__.py +19 -0
- hare/query/queryset/annotation_access_tracker.py +20 -0
- hare/query/queryset/arguments/__init__.py +1 -0
- hare/query/queryset/arguments/annotation_arguments.py +215 -0
- hare/query/queryset/arguments/collection_arguments.py +29 -0
- hare/query/queryset/arguments/filter_arguments.py +260 -0
- hare/query/queryset/arguments/ordering_arguments.py +242 -0
- hare/query/queryset/arguments/values_arguments.py +145 -0
- hare/query/queryset/combination/__init__.py +1 -0
- hare/query/queryset/combination/combination.py +58 -0
- hare/query/queryset/combination/queryset_combination.py +109 -0
- hare/query/queryset/concrete_field_paths.py +109 -0
- hare/query/queryset/constants.py +83 -0
- hare/query/queryset/date_lists.py +74 -0
- hare/query/queryset/declarations.py +7 -0
- hare/query/queryset/extensions/__init__.py +9 -0
- hare/query/queryset/extensions/query_set_extension.py +78 -0
- hare/query/queryset/extensions/query_set_extension_call.py +19 -0
- hare/query/queryset/extensions/query_set_extension_query.py +146 -0
- hare/query/queryset/extensions/query_set_extensions.py +247 -0
- hare/query/queryset/lazy_relation_names.py +33 -0
- hare/query/queryset/model_query.py +79 -0
- hare/query/queryset/objects_by_key.py +79 -0
- hare/query/queryset/options/__init__.py +1 -0
- hare/query/queryset/options/query_option.py +42 -0
- hare/query/queryset/options/query_options.py +313 -0
- hare/query/queryset/pending_calls/__init__.py +1 -0
- hare/query/queryset/pending_calls/calls_before_setup.py +185 -0
- hare/query/queryset/pending_calls/pending_filter_calls.py +144 -0
- hare/query/queryset/query_specification.py +1088 -0
- hare/query/queryset/queryset.py +2527 -0
- hare/query/queryset/relations/__init__.py +3 -0
- hare/query/queryset/relations/linked_many_to_many_relation.py +41 -0
- hare/query/queryset/relations/many_to_many/__init__.py +1 -0
- hare/query/queryset/relations/many_to_many/linked_keys.py +147 -0
- hare/query/queryset/relations/many_to_many/linked_rows_queries.py +175 -0
- hare/query/queryset/relations/many_to_many/many_to_many_members.py +173 -0
- hare/query/queryset/relations/many_to_many/many_to_many_scope_checks.py +332 -0
- hare/query/queryset/relations/many_to_many/through_defaults.py +244 -0
- hare/query/queryset/relations/many_to_many/through_row_inserting.py +516 -0
- hare/query/queryset/relations/many_to_many/through_row_unlinking.py +333 -0
- hare/query/queryset/relations/many_to_many/through_rows.py +185 -0
- hare/query/queryset/relations/many_to_many_relation.py +382 -0
- hare/query/queryset/relations/related_queryset/__init__.py +9 -0
- hare/query/queryset/relations/related_queryset/related_query_set.py +366 -0
- hare/query/queryset/relations/related_queryset/related_rows_iterator.py +42 -0
- hare/query/queryset/relations/related_queryset/relation_rows.py +73 -0
- hare/query/queryset/relations/related_queryset/unsaved_owner_condition.py +37 -0
- hare/query/queryset/relations/reverse_relation.py +474 -0
- hare/query/queryset/row_multiplication.py +151 -0
- hare/query/queryset/schema_object_calls.py +45 -0
- hare/query/queryset/selection/__init__.py +1 -0
- hare/query/queryset/selection/statement_selection.py +217 -0
- hare/query/queryset/selection/values_selection.py +65 -0
- hare/query/queryset/single_rows/__init__.py +1 -0
- hare/query/queryset/single_rows/get_exception_argument.py +7 -0
- hare/query/queryset/single_rows/get_exceptions.py +91 -0
- hare/query/queryset/single_rows/none_awaitable_type.py +21 -0
- hare/query/queryset/single_rows/query_set_single.py +49 -0
- hare/query/queryset/single_rows/single_row.py +103 -0
- hare/query/queryset/specification_copying.py +123 -0
- hare/query/queryset/table_sample.py +60 -0
- hare/query/raw_sql/__init__.py +6 -0
- hare/query/raw_sql/execute_sql.py +71 -0
- hare/query/raw_sql/sql_query_result.py +38 -0
- hare/query/relation_loading/__init__.py +14 -0
- hare/query/relation_loading/constants.py +8 -0
- hare/query/relation_loading/prefetching/__init__.py +1 -0
- hare/query/relation_loading/prefetching/declarations.py +32 -0
- hare/query/relation_loading/prefetching/direct_relation_prefetch.py +234 -0
- hare/query/relation_loading/prefetching/many_to_many_prefetch.py +496 -0
- hare/query/relation_loading/prefetching/prefetch.py +198 -0
- hare/query/relation_loading/prefetching/prefetch_checks.py +80 -0
- hare/query/relation_loading/prefetching/prefetch_related_objects.py +48 -0
- hare/query/relation_loading/prefetching/prefetch_request.py +30 -0
- hare/query/relation_loading/prefetching/prefetcher.py +200 -0
- hare/query/relation_loading/prefetching/related_rows_fetch.py +116 -0
- hare/query/relation_loading/prefetching/reverse_relation_prefetch.py +201 -0
- hare/query/relation_loading/prefetching/sliced_prefetch.py +165 -0
- hare/query/relation_loading/select.py +26 -0
- hare/query/rows/__init__.py +3 -0
- hare/query/rows/constants.py +33 -0
- hare/query/rows/enums.py +81 -0
- hare/query/rows/model_rows/__init__.py +1 -0
- hare/query/rows/model_rows/combined_model_rows.py +254 -0
- hare/query/rows/model_rows/model_columns.py +210 -0
- hare/query/rows/model_rows/model_rows.py +462 -0
- hare/query/rows/native/__init__.py +1 -0
- hare/query/rows/native/enums.py +12 -0
- hare/query/rows/native/field_codecs.py +450 -0
- hare/query/rows/native/hydrate_accelerator.py +264 -0
- hare/query/rows/native/hydration_layout.py +114 -0
- hare/query/rows/values_rows/__init__.py +1 -0
- hare/query/rows/values_rows/combined_values_rows.py +133 -0
- hare/query/rows/values_rows/dict_rows.py +92 -0
- hare/query/rows/values_rows/flat_rows.py +33 -0
- hare/query/rows/values_rows/named_rows.py +52 -0
- hare/query/rows/values_rows/tuple_rows.py +128 -0
- hare/query/rows/values_rows/value_field.py +26 -0
- hare/query/rows/values_rows/values_rows.py +175 -0
- hare/query/scopes/__init__.py +21 -0
- hare/query/scopes/constants.py +14 -0
- hare/query/scopes/manager_scope.py +51 -0
- hare/query/scopes/row_scope.py +46 -0
- hare/query/scopes/row_scopes.py +281 -0
- hare/query/scopes/row_visibility.py +89 -0
- hare/query/scopes/scope_join_conditions.py +273 -0
- hare/query/scopes/soft_delete_scope.py +17 -0
- hare/query/scopes/tenants/__init__.py +1 -0
- hare/query/scopes/tenants/all_tenants.py +11 -0
- hare/query/scopes/tenants/model_tenants.py +79 -0
- hare/query/scopes/tenants/tenant_scope.py +70 -0
- hare/query/scopes/tenants/tenant_values.py +52 -0
- hare/query/statements/__init__.py +30 -0
- hare/query/statements/awaitable_query.py +709 -0
- hare/query/statements/building/__init__.py +1 -0
- hare/query/statements/building/keyset_bounds.py +179 -0
- hare/query/statements/building/query_annotations.py +350 -0
- hare/query/statements/building/query_conditions.py +244 -0
- hare/query/statements/building/query_ctes.py +70 -0
- hare/query/statements/building/query_grouping.py +347 -0
- hare/query/statements/building/query_joins.py +282 -0
- hare/query/statements/building/query_ordering.py +275 -0
- hare/query/statements/building/row_locks.py +216 -0
- hare/query/statements/constants.py +111 -0
- hare/query/statements/select/__init__.py +4 -0
- hare/query/statements/select/combined/__init__.py +1 -0
- hare/query/statements/select/combined/combined_branches.py +380 -0
- hare/query/statements/select/combined/combined_derived_queries.py +220 -0
- hare/query/statements/select/combined/combined_plan_descriptions.py +43 -0
- hare/query/statements/select/combined_query.py +354 -0
- hare/query/statements/select/model_rows/__init__.py +1 -0
- hare/query/statements/select/model_rows/instance_hydration.py +162 -0
- hare/query/statements/select/model_rows/model_rows_plan_descriptions.py +108 -0
- hare/query/statements/select/model_rows/only_defer_fields.py +243 -0
- hare/query/statements/select/model_rows/select_related_joins.py +112 -0
- hare/query/statements/select/model_rows_query.py +416 -0
- hare/query/statements/select/raw_sql_query.py +151 -0
- hare/query/statements/select/rows_query.py +210 -0
- hare/query/statements/select/select_query.py +110 -0
- hare/query/statements/select/values/__init__.py +1 -0
- hare/query/statements/select/values/constants.py +9 -0
- hare/query/statements/select/values/values_distinct.py +41 -0
- hare/query/statements/select/values/values_grouping.py +118 -0
- hare/query/statements/select/values/values_output.py +298 -0
- hare/query/statements/select/values/values_reading.py +26 -0
- hare/query/statements/select/values/window_filter_wrapping.py +91 -0
- hare/query/statements/select/values_query.py +754 -0
- hare/query/statements/summary/__init__.py +3 -0
- hare/query/statements/summary/aggregate_query.py +732 -0
- hare/query/statements/summary/contains_query.py +66 -0
- hare/query/statements/summary/count_query.py +117 -0
- hare/query/statements/summary/exists_query.py +151 -0
- hare/query/statements/summary/rows_summary_query.py +187 -0
- hare/query/statements/write/__init__.py +3 -0
- hare/query/statements/write/bulk/__init__.py +1 -0
- hare/query/statements/write/bulk/bulk_objects.py +61 -0
- hare/query/statements/write/bulk/bulk_update_checks.py +92 -0
- hare/query/statements/write/bulk/bulk_update_query.py +1012 -0
- hare/query/statements/write/bulk/bulk_write_batches.py +368 -0
- hare/query/statements/write/bulk/create/__init__.py +1 -0
- hare/query/statements/write/bulk/create/bulk_create_query.py +936 -0
- hare/query/statements/write/bulk/create/bulk_create_reports.py +316 -0
- hare/query/statements/write/bulk/create/conflict_clause.py +137 -0
- hare/query/statements/write/bulk/create/copy_insert.py +143 -0
- hare/query/statements/write/bulk/create/default_rows_insert.py +85 -0
- hare/query/statements/write/bulk/create/inline_insert.py +93 -0
- hare/query/statements/write/bulk/create/multi_row_insert.py +277 -0
- hare/query/statements/write/bulk/create/returned_rows_matching.py +136 -0
- hare/query/statements/write/bulk/create/template_insert.py +185 -0
- hare/query/statements/write/bulk/declarations.py +61 -0
- hare/query/statements/write/create_or_update.py +193 -0
- hare/query/statements/write/declarations.py +26 -0
- hare/query/statements/write/delete_query.py +402 -0
- hare/query/statements/write/insert_from_query.py +373 -0
- hare/query/statements/write/matching_rows_query.py +268 -0
- hare/query/statements/write/merge/__init__.py +1 -0
- hare/query/statements/write/merge/merge_query.py +818 -0
- hare/query/statements/write/merge/merge_when.py +87 -0
- hare/query/statements/write/restore_query.py +105 -0
- hare/query/statements/write/returning/__init__.py +1 -0
- hare/query/statements/write/returning/delete_returning_query.py +154 -0
- hare/query/statements/write/returning/returned_rows.py +246 -0
- hare/query/statements/write/returning/update_returning_query.py +120 -0
- hare/query/statements/write/update_query.py +851 -0
- hare/search/__init__.py +29 -0
- hare/search/constants.py +22 -0
- hare/search/enums.py +26 -0
- hare/search/query/__init__.py +8 -0
- hare/search/query/combined_search_query.py +46 -0
- hare/search/query/declarations.py +9 -0
- hare/search/query/search_query.py +75 -0
- hare/search/query/search_query_combinable.py +40 -0
- hare/search/search_arguments.py +79 -0
- hare/search/search_features.py +35 -0
- hare/search/search_headline.py +186 -0
- hare/search/search_rank.py +144 -0
- hare/search/types.py +16 -0
- hare/search/vector/__init__.py +7 -0
- hare/search/vector/combined_search_vector.py +32 -0
- hare/search/vector/search_vector.py +77 -0
- hare/search/vector/search_vector_combinable.py +30 -0
- hare/sql/__init__.py +71 -0
- hare/sql/analytics/__init__.py +17 -0
- hare/sql/analytics/count.py +13 -0
- hare/sql/analytics/current_row.py +10 -0
- hare/sql/analytics/declarations.py +15 -0
- hare/sql/analytics/row_number.py +13 -0
- hare/sql/builder/__init__.py +29 -0
- hare/sql/builder/joins/__init__.py +16 -0
- hare/sql/builder/joins/join.py +71 -0
- hare/sql/builder/joins/join_on.py +73 -0
- hare/sql/builder/joins/joiner.py +38 -0
- hare/sql/builder/queries/__init__.py +17 -0
- hare/sql/builder/queries/constants.py +5 -0
- hare/sql/builder/queries/correlated_subqueries.py +583 -0
- hare/sql/builder/queries/pagination_sql.py +19 -0
- hare/sql/builder/queries/query.py +109 -0
- hare/sql/builder/queries/query_builder.py +1090 -0
- hare/sql/builder/queries/query_sql_rendering.py +407 -0
- hare/sql/builder/queries/set_operation_query.py +203 -0
- hare/sql/builder/returned_value.py +19 -0
- hare/sql/builder/tables/__init__.py +22 -0
- hare/sql/builder/tables/aliased_query.py +33 -0
- hare/sql/builder/tables/array_join_source.py +39 -0
- hare/sql/builder/tables/asof_join_source.py +29 -0
- hare/sql/builder/tables/cte.py +18 -0
- hare/sql/builder/tables/database.py +12 -0
- hare/sql/builder/tables/json_table_query.py +76 -0
- hare/sql/builder/tables/lateral_query.py +26 -0
- hare/sql/builder/tables/schema.py +42 -0
- hare/sql/builder/tables/selectable.py +83 -0
- hare/sql/builder/tables/table.py +170 -0
- hare/sql/builder_methods.py +56 -0
- hare/sql/constants.py +87 -0
- hare/sql/enums.py +211 -0
- hare/sql/exceptions.py +31 -0
- hare/sql/functions/__init__.py +81 -0
- hare/sql/functions/address_text.py +18 -0
- hare/sql/functions/cast.py +19 -0
- hare/sql/functions/cast_to.py +38 -0
- hare/sql/functions/coalesce.py +13 -0
- hare/sql/functions/count.py +14 -0
- hare/sql/functions/datetime/__init__.py +1 -0
- hare/sql/functions/datetime/date.py +16 -0
- hare/sql/functions/datetime/date_as_timestamp.py +23 -0
- hare/sql/functions/datetime/date_trunc.py +65 -0
- hare/sql/functions/datetime/datetime_as_text.py +16 -0
- hare/sql/functions/datetime/datetime_cast.py +68 -0
- hare/sql/functions/datetime/extract.py +92 -0
- hare/sql/functions/datetime/now.py +14 -0
- hare/sql/functions/datetime/temporal_difference.py +26 -0
- hare/sql/functions/datetime/temporal_shift.py +38 -0
- hare/sql/functions/datetime/timestamp_comparand.py +18 -0
- hare/sql/functions/declarations.py +19 -0
- hare/sql/functions/distinct_option_function.py +33 -0
- hare/sql/functions/greatest_least.py +25 -0
- hare/sql/functions/grouping_function.py +13 -0
- hare/sql/functions/json/__init__.py +1 -0
- hare/sql/functions/json/json_array.py +14 -0
- hare/sql/functions/json/json_object.py +14 -0
- hare/sql/functions/json/json_sort_key.py +15 -0
- hare/sql/functions/json/json_value.py +19 -0
- hare/sql/functions/numeric_cast.py +16 -0
- hare/sql/functions/random_number.py +13 -0
- hare/sql/functions/round.py +20 -0
- hare/sql/functions/statistic.py +20 -0
- hare/sql/functions/std_dev.py +13 -0
- hare/sql/functions/text/__init__.py +1 -0
- hare/sql/functions/text/collate.py +61 -0
- hare/sql/functions/text/concat.py +18 -0
- hare/sql/functions/text/concat_function.py +53 -0
- hare/sql/functions/text/decimal_text_collate.py +16 -0
- hare/sql/functions/text/lower.py +12 -0
- hare/sql/functions/text/replace.py +12 -0
- hare/sql/functions/text/upper.py +12 -0
- hare/sql/identifiers.py +61 -0
- hare/sql/sql_context.py +155 -0
- hare/sql/terms/__init__.py +90 -0
- hare/sql/terms/arithmetic_expression.py +120 -0
- hare/sql/terms/array.py +109 -0
- hare/sql/terms/bracket.py +12 -0
- hare/sql/terms/case/__init__.py +1 -0
- hare/sql/terms/case/case.py +123 -0
- hare/sql/terms/case/when_then.py +11 -0
- hare/sql/terms/constants.py +5 -0
- hare/sql/terms/containers/__init__.py +35 -0
- hare/sql/terms/containers/array_element_term.py +58 -0
- hare/sql/terms/containers/array_slice_term.py +28 -0
- hare/sql/terms/containers/constants.py +6 -0
- hare/sql/terms/containers/container_function.py +22 -0
- hare/sql/terms/containers/container_literal.py +37 -0
- hare/sql/terms/containers/declarations.py +47 -0
- hare/sql/terms/containers/map_value_term.py +30 -0
- hare/sql/terms/containers/tuple_element_term.py +21 -0
- hare/sql/terms/criteria/__init__.py +37 -0
- hare/sql/terms/criteria/basic_criterion.py +92 -0
- hare/sql/terms/criteria/between_criterion.py +39 -0
- hare/sql/terms/criteria/complex_criterion.py +47 -0
- hare/sql/terms/criteria/contains_criterion.py +81 -0
- hare/sql/terms/criteria/criterion.py +87 -0
- hare/sql/terms/criteria/empty_criterion.py +38 -0
- hare/sql/terms/criteria/is_distinct_from_criterion.py +52 -0
- hare/sql/terms/criteria/is_not_true_criterion.py +49 -0
- hare/sql/terms/criteria/json_attribute_criterion.py +62 -0
- hare/sql/terms/criteria/like.py +56 -0
- hare/sql/terms/criteria/nested_criterion.py +78 -0
- hare/sql/terms/criteria/not_criterion.py +78 -0
- hare/sql/terms/criteria/null_criterion.py +47 -0
- hare/sql/terms/criteria/range_criterion.py +28 -0
- hare/sql/terms/criteria/true_criterion.py +13 -0
- hare/sql/terms/field.py +65 -0
- hare/sql/terms/functions/__init__.py +30 -0
- hare/sql/terms/functions/aggregate_function.py +119 -0
- hare/sql/terms/functions/analytic_function.py +107 -0
- hare/sql/terms/functions/custom_function.py +39 -0
- hare/sql/terms/functions/decimal_mod.py +27 -0
- hare/sql/terms/functions/float_mod.py +24 -0
- hare/sql/terms/functions/function.py +131 -0
- hare/sql/terms/functions/interval.py +110 -0
- hare/sql/terms/functions/mod.py +22 -0
- hare/sql/terms/functions/pow.py +11 -0
- hare/sql/terms/functions/window_frame_analytic_function.py +78 -0
- hare/sql/terms/grouping/__init__.py +14 -0
- hare/sql/terms/grouping/declarations.py +17 -0
- hare/sql/terms/grouping/grouping_element.py +42 -0
- hare/sql/terms/grouping/grouping_sets_element.py +46 -0
- hare/sql/terms/index.py +15 -0
- hare/sql/terms/infix_operator.py +34 -0
- hare/sql/terms/json.py +100 -0
- hare/sql/terms/negative.py +49 -0
- hare/sql/terms/node.py +135 -0
- hare/sql/terms/parameters/__init__.py +1 -0
- hare/sql/terms/parameters/list_parameter.py +33 -0
- hare/sql/terms/parameters/parameter.py +35 -0
- hare/sql/terms/parameters/parameterized_value_wrapper.py +19 -0
- hare/sql/terms/parameters/parameterizer.py +99 -0
- hare/sql/terms/parameters/query_parameters.py +74 -0
- hare/sql/terms/parameters/recording_parameterizer.py +27 -0
- hare/sql/terms/qualified_outer_field.py +58 -0
- hare/sql/terms/select_reference.py +80 -0
- hare/sql/terms/star.py +30 -0
- hare/sql/terms/subqueries/__init__.py +1 -0
- hare/sql/terms/subqueries/exists_term.py +111 -0
- hare/sql/terms/subqueries/outer_aggregate_term.py +51 -0
- hare/sql/terms/term.py +334 -0
- hare/sql/terms/term_identity_text.py +60 -0
- hare/sql/terms/tuple.py +52 -0
- hare/sql/terms/values/__init__.py +1 -0
- hare/sql/terms/values/literal_value.py +21 -0
- hare/sql/terms/values/null_value.py +10 -0
- hare/sql/terms/values/old_row_value.py +28 -0
- hare/sql/terms/values/row_value_list.py +15 -0
- hare/sql/terms/values/value_wrapper.py +129 -0
- hare/sql/types/__init__.py +1 -0
- hare/sql/types/sql_type.py +13 -0
- hare/sql/types/sql_types.py +17 -0
- hare/stubs/__init__.py +2 -0
- hare/stubs/constants.py +18 -0
- hare/stubs/model_stub.py +415 -0
- hare/stubs/module_stub.py +150 -0
- hare/stubs/stub_imports.py +91 -0
- hare/stubs/stub_writer.py +60 -0
- hare/stubs/value_type_text.py +98 -0
- hare/time/__init__.py +12 -0
- hare/time/constants.py +27 -0
- hare/time/system_clock.py +84 -0
- hare/time/timezone.py +534 -0
- hare/time/zone_info.py +13 -0
- hare/transactions/__init__.py +25 -0
- hare/transactions/atomic/__init__.py +1 -0
- hare/transactions/atomic/atomic.py +138 -0
- hare/transactions/atomic/atomic_attempt.py +62 -0
- hare/transactions/atomic/atomic_attempts.py +73 -0
- hare/transactions/constants.py +41 -0
- hare/transactions/distributed/__init__.py +9 -0
- hare/transactions/distributed/declarations.py +32 -0
- hare/transactions/distributed/distributed_coordinator.py +784 -0
- hare/transactions/distributed/distributed_transactions.py +26 -0
- hare/transactions/distributed/stale_prepared_transaction.py +23 -0
- hare/transactions/enums.py +31 -0
- hare/transactions/transaction_options.py +86 -0
- hare/transactions/transactions.py +228 -0
- hare/typing_info/__init__.py +3 -0
- hare/typing_info/bound_models.py +73 -0
- hare/typing_info/constants.py +13 -0
- hare/typing_info/declarations.py +44 -0
- hare/typing_info/filter_value_types.py +144 -0
- hare/vectors/__init__.py +18 -0
- hare/vectors/constants.py +10 -0
- hare/vectors/declarations.py +41 -0
- hare/vectors/enums.py +14 -0
- hare/vectors/terms/__init__.py +6 -0
- hare/vectors/terms/vector_distance_term.py +22 -0
- hare/vectors/terms/vector_literal.py +18 -0
- hare/vectors/vector_distance_expression.py +107 -0
- hare/vectors/vector_field.py +147 -0
- hare/warnings.py +13 -0
- hare_orm-0.9.0.dist-info/LICENSE +27 -0
- hare_orm-0.9.0.dist-info/METADATA +321 -0
- hare_orm-0.9.0.dist-info/NOTICE.md +96 -0
- hare_orm-0.9.0.dist-info/NOTICE.ru.md +98 -0
- hare_orm-0.9.0.dist-info/RECORD +2267 -0
- hare_orm-0.9.0.dist-info/WHEEL +4 -0
- hare_orm-0.9.0.dist-info/entry_points.txt +6 -0
hare/fields/field.py
ADDED
|
@@ -0,0 +1,1231 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import contextlib
|
|
4
|
+
import contextvars
|
|
5
|
+
import inspect
|
|
6
|
+
import warnings
|
|
7
|
+
from collections.abc import Callable, Generator
|
|
8
|
+
from copy import deepcopy
|
|
9
|
+
from enum import Enum
|
|
10
|
+
from typing import TYPE_CHECKING, Any, ClassVar, Generic, TypeVar, cast, overload
|
|
11
|
+
|
|
12
|
+
from hare.classes.class_path import ClassPath
|
|
13
|
+
from hare.core.caching.cache import Cache
|
|
14
|
+
from hare.core.registries import Registries
|
|
15
|
+
from hare.dialects.base.literals.constants import SQL_NULL_BYTE
|
|
16
|
+
from hare.dialects.dialect_registry import DialectRegistry
|
|
17
|
+
from hare.exceptions import ConfigurationError, DatabaseError, UnSupportedError, ValidationError
|
|
18
|
+
from hare.fields.constants import (
|
|
19
|
+
DB_DEFAULT_NOT_SET,
|
|
20
|
+
SCHEMA_TEXT_NULL_BYTE_MESSAGE,
|
|
21
|
+
SENSITIVE_VALUE_PLACEHOLDER,
|
|
22
|
+
UNWRITTEN_FIELD_CONSTRUCTOR_PARAMETERS,
|
|
23
|
+
)
|
|
24
|
+
from hare.fields.db_default_not_set import DbDefaultNotSet
|
|
25
|
+
from hare.fields.enums import NativeWriteCheck, RelationType
|
|
26
|
+
from hare.fields.registrations.registered_lookup import RegisteredLookup
|
|
27
|
+
from hare.fields.registrations.registered_transform import RegisteredTransform
|
|
28
|
+
from hare.fields.relations.swappable_model_reference import SwappableModelReference
|
|
29
|
+
from hare.fields.validators.validator import Validator
|
|
30
|
+
from hare.query.enums import LookupValueShape
|
|
31
|
+
from hare.sql.enums import DateTruncSource
|
|
32
|
+
from hare.sql.terms.term import Term
|
|
33
|
+
from hare.warnings import RedundantDbDefaultWarning
|
|
34
|
+
|
|
35
|
+
if TYPE_CHECKING:
|
|
36
|
+
from typing import Self
|
|
37
|
+
|
|
38
|
+
from hare.ddl.schema_objects.enum_type import EnumType
|
|
39
|
+
from hare.dialects.base.client.database_client import DatabaseClient
|
|
40
|
+
from hare.dialects.base.dialect import Dialect
|
|
41
|
+
from hare.dialects.base.types.type_registry import TypeRegistry
|
|
42
|
+
from hare.fields.narrowing.narrowing_limit import NarrowingLimit
|
|
43
|
+
from hare.models import Model
|
|
44
|
+
from hare.query.filters.lookups.field_lookup import FieldLookup
|
|
45
|
+
|
|
46
|
+
LookupFunction = Callable[["Field[Any] | None"], FieldLookup]
|
|
47
|
+
from hare.classes.value_descriptions import ValueDescriptions
|
|
48
|
+
from hare.fields.database_default import DatabaseDefault
|
|
49
|
+
from hare.fields.field_meta import FieldMeta
|
|
50
|
+
|
|
51
|
+
TValue = TypeVar("TValue")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class Field(Generic[TValue], metaclass=FieldMeta):
|
|
55
|
+
"""The base of every field: a value of a model and, unless the field is virtual, its column.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
source_field: The column's name, when it isn't the field's name.
|
|
59
|
+
generated: Whether the database generates the value - the column is left out of every INSERT.
|
|
60
|
+
primary_key: Whether the field is the model's primary key. A model declaring none gets an
|
|
61
|
+
``id`` key.
|
|
62
|
+
null: Whether the field takes ``None`` - a ``NULL`` column.
|
|
63
|
+
default: The value of a field the constructor isn't given - a callable is called for each
|
|
64
|
+
object, a coroutine function awaited on save. It isn't part of the schema.
|
|
65
|
+
db_default: The column's default in the database - a value or a ``SqlDefault``.
|
|
66
|
+
unique: Whether the column is unique.
|
|
67
|
+
db_index: Whether the column has an index of its own.
|
|
68
|
+
description: The column's comment in the generated DDL.
|
|
69
|
+
validators: The validators of the field's values.
|
|
70
|
+
sensitive: Whether the field holds secret data (credentials, tokens, personal data): listed
|
|
71
|
+
in ``Model._meta.sensitive_fields``, hidden in error messages and dropped by
|
|
72
|
+
``pydantic_model_creator(..., exclude_sensitive=True)``. The schema doesn't change.
|
|
73
|
+
|
|
74
|
+
**Class attributes** a field class declares:
|
|
75
|
+
|
|
76
|
+
.. attribute:: field_type
|
|
77
|
+
:annotation: type[Any]
|
|
78
|
+
|
|
79
|
+
The Python type of the field's values.
|
|
80
|
+
|
|
81
|
+
.. attribute:: indexable
|
|
82
|
+
:annotation: bool = True
|
|
83
|
+
|
|
84
|
+
Whether a plain index holds the column - False where it can't be indexed reliably.
|
|
85
|
+
|
|
86
|
+
.. attribute:: has_db_field
|
|
87
|
+
:annotation: bool = True
|
|
88
|
+
|
|
89
|
+
Whether the field has a column of its own - a relation's accessor or a virtual field has none.
|
|
90
|
+
|
|
91
|
+
.. attribute:: is_orderable
|
|
92
|
+
:annotation: bool = True
|
|
93
|
+
|
|
94
|
+
Whether the database orders rows by the field's column - ``order_by()`` on a field that
|
|
95
|
+
isn't raises ``UnSupportedError``.
|
|
96
|
+
|
|
97
|
+
.. attribute:: keeps_native_db_values
|
|
98
|
+
:annotation: bool = True
|
|
99
|
+
|
|
100
|
+
Whether a value the driver already returns as ``field_type`` is read as it is, without
|
|
101
|
+
``from_db_value()``. A class defining ``to_python()`` or ``from_db_value()`` reads every
|
|
102
|
+
value through them unless it declares this itself.
|
|
103
|
+
|
|
104
|
+
.. attribute:: native_write_check
|
|
105
|
+
:annotation: NativeWriteCheck | None = None
|
|
106
|
+
|
|
107
|
+
Declared by a field class whose own ``to_db_value`` adds checks to
|
|
108
|
+
``Field.to_db_value``: what those checks do for a value that is already exactly
|
|
109
|
+
``field_type``. The Rust write accelerator runs that check itself and keeps the field on
|
|
110
|
+
its fast path; any other value goes through the class's real ``to_db_value``. Read only
|
|
111
|
+
from the class that defines the ``to_db_value`` in use - a subclass overriding
|
|
112
|
+
``to_db_value`` again leaves the fast path until it declares its own.
|
|
113
|
+
|
|
114
|
+
.. attribute:: allows_generated
|
|
115
|
+
:annotation: bool = False
|
|
116
|
+
|
|
117
|
+
Whether the database can generate the field's value (``generated=True``).
|
|
118
|
+
|
|
119
|
+
.. attribute:: generated_requires_primary_key
|
|
120
|
+
:annotation: bool = False
|
|
121
|
+
|
|
122
|
+
Whether hare can only create this field's column as a DB-generated primary key - its
|
|
123
|
+
``GENERATED_SQL`` is an auto-increment primary key definition. A generated non-primary-key
|
|
124
|
+
field of such a class still maps an existing column (e.g. an IDENTITY column).
|
|
125
|
+
|
|
126
|
+
.. attribute:: requires_enum_type
|
|
127
|
+
:annotation: Optional[EnumType] = None
|
|
128
|
+
|
|
129
|
+
The database ``ENUM`` type this field's column is of. The migration autodetector creates,
|
|
130
|
+
changes and drops the type with the fields using it; ``generate_schemas()`` creates it
|
|
131
|
+
before the tables.
|
|
132
|
+
|
|
133
|
+
.. attribute:: supported_lookups
|
|
134
|
+
:annotation: Optional[frozenset[str]] = None
|
|
135
|
+
|
|
136
|
+
Lookup suffixes (``"isnull"``, ``"has_key"``, ...) still usable on this field - a
|
|
137
|
+
value-comparing lookup can't work on e.g. a non-deterministically encrypted column.
|
|
138
|
+
``None`` means every lookup is usable.
|
|
139
|
+
|
|
140
|
+
.. attribute:: relation_type
|
|
141
|
+
:annotation: Optional[RelationType] = None
|
|
142
|
+
|
|
143
|
+
Which relation the field is (``RelationType.FOREIGN_KEY``, ``ONE_TO_ONE``,
|
|
144
|
+
``MANY_TO_MANY`` and the two backward sides); ``None`` for a field holding a plain value.
|
|
145
|
+
|
|
146
|
+
.. attribute:: encrypted
|
|
147
|
+
:annotation: bool = False
|
|
148
|
+
|
|
149
|
+
Whether the field stores its value encrypted (``EncryptedTextField``,
|
|
150
|
+
``EncryptedJSONField``) - the database sees only ciphertext, so the field can't be
|
|
151
|
+
compared by value, ordered, grouped or aggregated.
|
|
152
|
+
|
|
153
|
+
.. attribute:: enum_type
|
|
154
|
+
:annotation: Optional[type[Enum]] = None
|
|
155
|
+
|
|
156
|
+
The enum class whose members the field holds (``IntEnumField``, ``CharEnumField``);
|
|
157
|
+
``None`` for any other field.
|
|
158
|
+
|
|
159
|
+
.. attribute:: SQL_TYPE
|
|
160
|
+
:annotation: str
|
|
161
|
+
|
|
162
|
+
The column type, unless the dialect's type registry gives another.
|
|
163
|
+
|
|
164
|
+
.. attribute:: GENERATED_SQL
|
|
165
|
+
:annotation: str
|
|
166
|
+
|
|
167
|
+
The column definition of a generated value - needed with ``allows_generated``.
|
|
168
|
+
|
|
169
|
+
.. attribute:: COLUMN_TYPE_FROM_DIALECT
|
|
170
|
+
:annotation: bool = False
|
|
171
|
+
|
|
172
|
+
The field exists on the dialects whose types give it a column type
|
|
173
|
+
(``TypeMapping.column_type`` registered for its class or a class between it and the class
|
|
174
|
+
setting this) - a field of one database is registered by that database's dialect.
|
|
175
|
+
|
|
176
|
+
**Per-dialect storage:**
|
|
177
|
+
|
|
178
|
+
A dialect stores a field class its own way through its type registry - a column type, the
|
|
179
|
+
DDL of a generated primary key and a cast wrapped around the column wherever it is compared
|
|
180
|
+
(``hare.dialects.base.types.TypeMapping``). A field class uses the mapping of its nearest
|
|
181
|
+
registered base class:
|
|
182
|
+
|
|
183
|
+
.. code-block:: py3
|
|
184
|
+
|
|
185
|
+
DialectRegistry.get_dialect("sqlite").types.register(MoneyField, TypeMapping(column_type="TEXT"))
|
|
186
|
+
"""
|
|
187
|
+
|
|
188
|
+
field_type: type[Any] = None # type: ignore[assignment]
|
|
189
|
+
indexable: bool = True
|
|
190
|
+
has_db_field: bool = True
|
|
191
|
+
is_orderable: ClassVar[bool] = True
|
|
192
|
+
keeps_native_db_values: ClassVar[bool] = True
|
|
193
|
+
#: The type of its values a function refusing types of arguments tells the field by, when the
|
|
194
|
+
#: neutral types of values name none - a dialect's field declares it.
|
|
195
|
+
argument_value_type: ClassVar[str | None] = None
|
|
196
|
+
#: The constructor parameters of the field's class a migration doesn't write, besides the ones no
|
|
197
|
+
#: field's migration writes.
|
|
198
|
+
unwritten_constructor_parameters: ClassVar[frozenset[str]] = frozenset()
|
|
199
|
+
native_write_check: ClassVar[NativeWriteCheck | None] = None
|
|
200
|
+
allows_generated: bool = False
|
|
201
|
+
generated_requires_primary_key: bool = False
|
|
202
|
+
requires_enum_type: EnumType | None = None
|
|
203
|
+
supported_lookups: frozenset[str] | None = None
|
|
204
|
+
relation_type: ClassVar[RelationType | None] = None
|
|
205
|
+
encrypted: ClassVar[bool] = False
|
|
206
|
+
#: True while a historical migration file is being imported - its fields describe a schema
|
|
207
|
+
#: that was already applied, so today's construction rules (the SET_DEFAULT requirement of a
|
|
208
|
+
#: foreign key, the ``db_index`` default) don't apply.
|
|
209
|
+
replaying_migration: ClassVar[contextvars.ContextVar[bool]] = contextvars.ContextVar(
|
|
210
|
+
"hare_replaying_migration", default=False
|
|
211
|
+
)
|
|
212
|
+
#: The ``db_index`` a field gets when none is passed. A migration file replays an omitted
|
|
213
|
+
#: ``db_index`` as False, the value it was written with.
|
|
214
|
+
indexed_by_default: ClassVar[bool] = False
|
|
215
|
+
enum_type: type[Enum] | None = None
|
|
216
|
+
SQL_TYPE: str = None # type: ignore[assignment]
|
|
217
|
+
GENERATED_SQL: str = None # type: ignore[assignment]
|
|
218
|
+
COLUMN_TYPE_FROM_DIALECT: ClassVar[bool] = False
|
|
219
|
+
#: The ``Features`` flag a connection needs to read a path inside the field's value (a
|
|
220
|
+
#: geometry's ``__x``); a filter through such a path raises ``UnSupportedError`` before any SQL
|
|
221
|
+
#: without it. None for no flag.
|
|
222
|
+
path_required_feature: ClassVar[str | None] = None
|
|
223
|
+
# A custom Field subclass can set a stable "dotted path" here (e.g. "myapp.fields.MyField") -
|
|
224
|
+
# generated migrations then always import from this path instead of `__module__`, which
|
|
225
|
+
# changes whenever the class is moved between modules.
|
|
226
|
+
migration_import_path: str | None = None
|
|
227
|
+
|
|
228
|
+
#: Whether the field's value is an array, a range or a JSON value - an annotation of such a
|
|
229
|
+
#: field takes the value's own lookups (``__contains``, ``__overlap``, ``__len``, ...).
|
|
230
|
+
holds_container_value: ClassVar[bool] = False
|
|
231
|
+
#: The type of date/time value ``Extract()`` and ``Trunc()`` read the field's value as - None for
|
|
232
|
+
#: a field holding none.
|
|
233
|
+
date_function_source: ClassVar[DateTruncSource | None] = None
|
|
234
|
+
#: The field ``Trunc(..., "time")`` reads the wall clock time of a ``NAIVE_DATETIME`` value
|
|
235
|
+
#: through - None for any other field.
|
|
236
|
+
time_of_day_output_field: ClassVar[Field[Any] | None] = None
|
|
237
|
+
|
|
238
|
+
#: Registry of custom `__suffix` lookups, populated via register_lookup().
|
|
239
|
+
registered_lookups: ClassVar[dict[str, RegisteredLookup]] = {}
|
|
240
|
+
#: Path segments added to this class with register_transform(), by segment.
|
|
241
|
+
registered_transforms: ClassVar[dict[str, RegisteredTransform]] = {}
|
|
242
|
+
#: (field class,) -> its constructor's parameters other than ``self``, with their defaults
|
|
243
|
+
#: (``_get_constructor_parameters()``).
|
|
244
|
+
constructor_parameters: ClassVar[Cache[tuple[tuple[str, Any], ...]]] = Cache(Cache.max_size_from_env())
|
|
245
|
+
#: The field's lookups by suffix, with the generation of ``FieldLookups.built_lookups`` they
|
|
246
|
+
#: were built in - never copied with the field.
|
|
247
|
+
built_lookups: tuple[int, dict[str, FieldLookup]] | None = None
|
|
248
|
+
|
|
249
|
+
@classmethod
|
|
250
|
+
def register_lookup(
|
|
251
|
+
cls,
|
|
252
|
+
lookup_name: str,
|
|
253
|
+
lookup: LookupFunction | None = None,
|
|
254
|
+
*,
|
|
255
|
+
value_shape: LookupValueShape = LookupValueShape.VALUE,
|
|
256
|
+
value_type: Any = None,
|
|
257
|
+
required_extension: str | None = None,
|
|
258
|
+
) -> Callable[[LookupFunction], LookupFunction] | None:
|
|
259
|
+
"""Registers a ``__{lookup_name}`` lookup for this field class and its subclasses. Registered
|
|
260
|
+
on ``Field`` itself, it is a lookup of every value, a value with no field included
|
|
261
|
+
(``lookup`` then gets None). Can be called any time - later, the registries' caches are
|
|
262
|
+
dropped and the bound models' filters rebuilt. The filter value's shape is part of the
|
|
263
|
+
lookup: ``get_lookup_info()`` reports it. A lookup of one database has an operator marked by
|
|
264
|
+
``DialectImplementedOperators.mark()`` that the database's dialect implements
|
|
265
|
+
(``FilterOperators.register_operator()``) - a query on another raises ``UnSupportedError``
|
|
266
|
+
before any SQL is built.
|
|
267
|
+
|
|
268
|
+
Args:
|
|
269
|
+
lookup_name: The suffix without the double underscore (``"within_km"``).
|
|
270
|
+
lookup: ``(field) -> FieldLookup`` - omitted to use this as a decorator.
|
|
271
|
+
value_shape: Whether the value is one value, a list or a two-item range.
|
|
272
|
+
value_type: The type of the value (of each item); None means the field's own type.
|
|
273
|
+
required_extension: The database extension the lookup needs.
|
|
274
|
+
|
|
275
|
+
Returns:
|
|
276
|
+
None when called directly; a decorator when ``lookup`` is omitted.
|
|
277
|
+
"""
|
|
278
|
+
if lookup is None:
|
|
279
|
+
|
|
280
|
+
def decorator(lookup_function: LookupFunction) -> LookupFunction:
|
|
281
|
+
cls.register_lookup(
|
|
282
|
+
lookup_name,
|
|
283
|
+
lookup_function,
|
|
284
|
+
value_shape=value_shape,
|
|
285
|
+
value_type=value_type,
|
|
286
|
+
required_extension=required_extension,
|
|
287
|
+
)
|
|
288
|
+
return lookup_function
|
|
289
|
+
|
|
290
|
+
return decorator
|
|
291
|
+
if "registered_lookups" not in cls.__dict__:
|
|
292
|
+
cls.registered_lookups = {}
|
|
293
|
+
cls.registered_lookups[lookup_name] = RegisteredLookup(
|
|
294
|
+
builder=lookup,
|
|
295
|
+
value_shape=value_shape,
|
|
296
|
+
value_type=value_type,
|
|
297
|
+
required_extension=required_extension,
|
|
298
|
+
)
|
|
299
|
+
Registries.changed()
|
|
300
|
+
return None
|
|
301
|
+
|
|
302
|
+
# The types of a field read off a model class and off an instance, for type checkers.
|
|
303
|
+
if TYPE_CHECKING:
|
|
304
|
+
|
|
305
|
+
def __new__(cls, *args: Any, **kwargs: Any) -> Self:
|
|
306
|
+
return super().__new__(cls)
|
|
307
|
+
|
|
308
|
+
@overload
|
|
309
|
+
def __get__(self, obj: None, owner: type[Model]) -> Field[TValue]: ...
|
|
310
|
+
|
|
311
|
+
@overload
|
|
312
|
+
def __get__(self, obj: Model, owner: type[Model]) -> TValue: ...
|
|
313
|
+
|
|
314
|
+
# A field held by anything but a model - an expression's result, a declaration - is the field.
|
|
315
|
+
@overload
|
|
316
|
+
def __get__(self, obj: object, owner: type[object]) -> Field[TValue]: ...
|
|
317
|
+
|
|
318
|
+
def __get__(self, obj: object, owner: type[object]) -> Field[TValue] | TValue: ...
|
|
319
|
+
|
|
320
|
+
def __set__(self, obj: Model, value: TValue) -> None: ...
|
|
321
|
+
|
|
322
|
+
def _raise_if_texts_mistyped(self, *, source_field: Any, description: Any) -> None:
|
|
323
|
+
"""Refuses a column name or a description that isn't a text - both are written into the schema.
|
|
324
|
+
|
|
325
|
+
Args:
|
|
326
|
+
source_field: The column's name.
|
|
327
|
+
description: The column's comment.
|
|
328
|
+
|
|
329
|
+
Raises:
|
|
330
|
+
ConfigurationError: Either is neither None nor a text.
|
|
331
|
+
"""
|
|
332
|
+
name = self.__class__.__name__
|
|
333
|
+
for parameter, value in (("source_field", source_field), ("description", description)):
|
|
334
|
+
if value is not None and not isinstance(value, str):
|
|
335
|
+
raise ConfigurationError(f"{name}: {parameter} must be a text or None, got {value!r}")
|
|
336
|
+
|
|
337
|
+
def raise_if_schema_text_holds_null_byte(self, **texts: Any) -> None:
|
|
338
|
+
"""Refuses a text written into the schema - the description, a text ``default`` or
|
|
339
|
+
``db_default`` - that holds a null byte: no SQL text can hold one, and a migration would fail
|
|
340
|
+
only where it writes it, part of it applied.
|
|
341
|
+
|
|
342
|
+
Args:
|
|
343
|
+
texts: The values by parameter name - any but a text is left alone.
|
|
344
|
+
|
|
345
|
+
Raises:
|
|
346
|
+
ConfigurationError: A text holds a null byte.
|
|
347
|
+
"""
|
|
348
|
+
for parameter, value in texts.items():
|
|
349
|
+
if isinstance(value, str) and SQL_NULL_BYTE in value:
|
|
350
|
+
raise ConfigurationError(
|
|
351
|
+
SCHEMA_TEXT_NULL_BYTE_MESSAGE.format(owner=self.__class__.__name__, parameter=parameter)
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
def __init__(
|
|
355
|
+
self,
|
|
356
|
+
*,
|
|
357
|
+
source_field: str | None = None,
|
|
358
|
+
generated: bool = False,
|
|
359
|
+
primary_key: bool | None = None,
|
|
360
|
+
null: bool = False,
|
|
361
|
+
default: Any = None,
|
|
362
|
+
db_default: Any = DB_DEFAULT_NOT_SET,
|
|
363
|
+
unique: bool = False,
|
|
364
|
+
db_index: bool | None = None,
|
|
365
|
+
description: str | None = None,
|
|
366
|
+
validators: list[Validator | Callable[[Any], None]] | None = None,
|
|
367
|
+
sensitive: bool = False,
|
|
368
|
+
**kwargs: Any,
|
|
369
|
+
) -> None:
|
|
370
|
+
if kwargs:
|
|
371
|
+
raise TypeError(
|
|
372
|
+
f"{self.__class__.__name__}() got unexpected keyword arguments: {', '.join(sorted(kwargs))}"
|
|
373
|
+
)
|
|
374
|
+
self._raise_if_texts_mistyped(source_field=source_field, description=description)
|
|
375
|
+
self.raise_if_schema_text_holds_null_byte(description=description, default=default, db_default=db_default)
|
|
376
|
+
if null and primary_key:
|
|
377
|
+
raise ConfigurationError(f"{self.__class__.__name__} can't be both null=True and primary_key=True")
|
|
378
|
+
if db_index is None:
|
|
379
|
+
db_index = self.indexed_by_default and not self.replaying_migration.get()
|
|
380
|
+
if primary_key and self.indexable:
|
|
381
|
+
# Not for a type that can't be indexed - the PRIMARY KEY constraint already covers it.
|
|
382
|
+
db_index = True
|
|
383
|
+
unique = True
|
|
384
|
+
if not self.indexable and (unique or db_index):
|
|
385
|
+
raise ConfigurationError(f"{self.__class__.__name__} can't be indexed")
|
|
386
|
+
self.source_field = source_field
|
|
387
|
+
self.generated = generated
|
|
388
|
+
self.pk = bool(primary_key)
|
|
389
|
+
self.default = default
|
|
390
|
+
# Cached: the check is slow, and Model.__init__ would run it per instance.
|
|
391
|
+
self._default_is_coroutine = self._is_async_default(default)
|
|
392
|
+
#: Whether the static ``default`` already has the form ``to_python`` gives
|
|
393
|
+
#: it - None until the first instance construction checks it.
|
|
394
|
+
self.static_default_is_normalized: bool | None = None
|
|
395
|
+
#: ``get_assign_normalized_types()``, cached by the first callable default normalized.
|
|
396
|
+
self.assign_normalized_types: frozenset[type] | None = None
|
|
397
|
+
#: ``(validators, their count, the native checks of them)`` - the checks ``validate()`` makes
|
|
398
|
+
#: of a value of exactly ``field_type``, worked out by its first such value.
|
|
399
|
+
self.value_checks: tuple[list[Any], int, Any] | None = None
|
|
400
|
+
self.db_default = db_default
|
|
401
|
+
if self.has_db_default() and callable(self.db_default):
|
|
402
|
+
raise ConfigurationError(
|
|
403
|
+
f"{self.__class__.__name__}: db_default must be a static value or SqlDefault(...), not a callable"
|
|
404
|
+
)
|
|
405
|
+
if default is not None and self.has_db_default() and self.is_db_default_redundant_with_default():
|
|
406
|
+
warnings.warn(
|
|
407
|
+
f"{self.__class__.__name__}: both `default` and `db_default` are set - `db_default` will never"
|
|
408
|
+
" be applied since `default` always provides a value before an INSERT is sent to the database.",
|
|
409
|
+
RedundantDbDefaultWarning,
|
|
410
|
+
stacklevel=2,
|
|
411
|
+
)
|
|
412
|
+
if default is not None and self.generated:
|
|
413
|
+
# A generated column is left out of every INSERT - its default is never used.
|
|
414
|
+
warnings.warn(
|
|
415
|
+
f"{self.__class__.__name__}: `default` is set on a generated field - it will never be applied "
|
|
416
|
+
"since a generated column's value always comes from the database, never from an INSERT.",
|
|
417
|
+
RedundantDbDefaultWarning,
|
|
418
|
+
stacklevel=2,
|
|
419
|
+
)
|
|
420
|
+
self.null = null
|
|
421
|
+
self.unique = unique
|
|
422
|
+
self.index = bool(db_index)
|
|
423
|
+
self.model_field_name = ""
|
|
424
|
+
self.description = description
|
|
425
|
+
self.docstring: str | None = None
|
|
426
|
+
self.validators: list[Validator | Callable[[Any], None]] = validators or []
|
|
427
|
+
self.sensitive = sensitive
|
|
428
|
+
# Bound by the model class that declares the field.
|
|
429
|
+
self.model: type[Model] = None # type: ignore[assignment]
|
|
430
|
+
self.reference: Field[Any] | None = None
|
|
431
|
+
|
|
432
|
+
def __getstate__(self) -> dict[str, Any]:
|
|
433
|
+
state = self.__dict__.copy()
|
|
434
|
+
state.pop("built_lookups", None)
|
|
435
|
+
# Worked out again by the copy's first value - the native checks can't be copied.
|
|
436
|
+
state["value_checks"] = None
|
|
437
|
+
return state
|
|
438
|
+
|
|
439
|
+
def __copy__(self) -> Field[TValue]:
|
|
440
|
+
cls = self.__class__
|
|
441
|
+
result = cls.__new__(cls)
|
|
442
|
+
result.__dict__.update(self.__getstate__())
|
|
443
|
+
result.validators = list(self.validators)
|
|
444
|
+
return result
|
|
445
|
+
|
|
446
|
+
def to_db_value(self, value: Any, instance: type[Model] | Model | None) -> Any:
|
|
447
|
+
"""The value written into the column for a Python value - converted to ``field_type`` and validated.
|
|
448
|
+
|
|
449
|
+
Args:
|
|
450
|
+
value: The Python value.
|
|
451
|
+
instance: The model class or the instance the value is written for - an instance has
|
|
452
|
+
``_saved_in_db``.
|
|
453
|
+
|
|
454
|
+
Returns:
|
|
455
|
+
The value to write.
|
|
456
|
+
|
|
457
|
+
Raises:
|
|
458
|
+
ValidationError: The value doesn't convert, or a validator refuses it.
|
|
459
|
+
"""
|
|
460
|
+
if value is not None and not isinstance(value, self.field_type):
|
|
461
|
+
value = self.get_written_value_of_another_type(value)
|
|
462
|
+
self.validate(value)
|
|
463
|
+
return value
|
|
464
|
+
|
|
465
|
+
def get_written_value_of_another_type(self, value: Any) -> Any:
|
|
466
|
+
"""The value a write takes of a value of another type than ``field_type`` - converted as
|
|
467
|
+
``Field.to_python()`` converts it.
|
|
468
|
+
|
|
469
|
+
Args:
|
|
470
|
+
value: The value, not None.
|
|
471
|
+
|
|
472
|
+
Returns:
|
|
473
|
+
The value as ``field_type``.
|
|
474
|
+
|
|
475
|
+
Raises:
|
|
476
|
+
ValidationError: The value doesn't convert.
|
|
477
|
+
"""
|
|
478
|
+
return Field.to_python(self, value)
|
|
479
|
+
|
|
480
|
+
def get_validation_error(self, error: BaseException, value: Any, message: str | None = None) -> ValidationError:
|
|
481
|
+
"""Wraps an exception raised while converting or validating ``value``. For a sensitive field
|
|
482
|
+
the message hides the value and ``error`` isn't chained.
|
|
483
|
+
|
|
484
|
+
Args:
|
|
485
|
+
error: The exception raised.
|
|
486
|
+
value: The value.
|
|
487
|
+
message: The full message, instead of the field name followed by ``error``'s text.
|
|
488
|
+
|
|
489
|
+
Returns:
|
|
490
|
+
The error to raise.
|
|
491
|
+
"""
|
|
492
|
+
if message is None:
|
|
493
|
+
message = f"{self.model_field_name}: {self.hide_value_in_message(str(error), value)}"
|
|
494
|
+
validation_error = ValidationError(message)
|
|
495
|
+
if not self.sensitive:
|
|
496
|
+
validation_error.__cause__ = error
|
|
497
|
+
return validation_error
|
|
498
|
+
|
|
499
|
+
def get_value_for_message(self, value: Any) -> str:
|
|
500
|
+
"""Returns how ``value`` is shown in an error message.
|
|
501
|
+
|
|
502
|
+
Args:
|
|
503
|
+
value: The value.
|
|
504
|
+
|
|
505
|
+
Returns:
|
|
506
|
+
Its repr cut short (``ValueDescriptions.get_shown_value()``), or a placeholder for a
|
|
507
|
+
sensitive field.
|
|
508
|
+
"""
|
|
509
|
+
return SENSITIVE_VALUE_PLACEHOLDER if self.sensitive else ValueDescriptions.get_shown_value(value)
|
|
510
|
+
|
|
511
|
+
def hide_value_in_message(self, message: str, value: Any) -> str:
|
|
512
|
+
"""Replaces every occurrence of ``value`` in a sensitive field's error message with a
|
|
513
|
+
placeholder.
|
|
514
|
+
|
|
515
|
+
Args:
|
|
516
|
+
message: The error message.
|
|
517
|
+
value: The value the message may contain.
|
|
518
|
+
|
|
519
|
+
Returns:
|
|
520
|
+
The message, unchanged for a non-sensitive field.
|
|
521
|
+
"""
|
|
522
|
+
if not self.sensitive or value is None:
|
|
523
|
+
return message
|
|
524
|
+
shown_values = [ValueDescriptions.get_shown_value(value), ValueDescriptions.get_shown_text(value)]
|
|
525
|
+
if not isinstance(value, (list, tuple, dict, set, frozenset)):
|
|
526
|
+
shown_values += [repr(value), str(value)]
|
|
527
|
+
if isinstance(value, Enum):
|
|
528
|
+
shown_values += [repr(value.value), str(value.value)]
|
|
529
|
+
for shown_value in sorted(shown_values, key=len, reverse=True):
|
|
530
|
+
if shown_value:
|
|
531
|
+
message = message.replace(f"'{shown_value}'", SENSITIVE_VALUE_PLACEHOLDER)
|
|
532
|
+
message = DatabaseError.hide_text(message, shown_value, SENSITIVE_VALUE_PLACEHOLDER)
|
|
533
|
+
return message
|
|
534
|
+
|
|
535
|
+
def to_lookup_value(self, value: Any, instance: type[Model] | Model | None) -> Any:
|
|
536
|
+
"""The value a filter compares the column with - the written one by default; a field reading a
|
|
537
|
+
filter's value otherwise overrides it.
|
|
538
|
+
|
|
539
|
+
Args:
|
|
540
|
+
value: The filter's value.
|
|
541
|
+
instance: The model class the filter is built for.
|
|
542
|
+
|
|
543
|
+
Returns:
|
|
544
|
+
The value to compare with.
|
|
545
|
+
"""
|
|
546
|
+
return self.to_db_value(value, instance)
|
|
547
|
+
|
|
548
|
+
def get_unsupported_lookup_message(self) -> str:
|
|
549
|
+
"""Returns the error message for a lookup outside ``supported_lookups``."""
|
|
550
|
+
supported = ", ".join(f"__{lookup}" if lookup else "=" for lookup in sorted(self.supported_lookups or ()))
|
|
551
|
+
return (
|
|
552
|
+
f"{self.model_field_name}: this lookup isn't supported on {type(self).__name__}. "
|
|
553
|
+
f"Supported lookups: {supported}."
|
|
554
|
+
)
|
|
555
|
+
|
|
556
|
+
def to_python(self, value: Any) -> Any:
|
|
557
|
+
"""The field's Python value of ``value`` - a value assigned to an instance, and a value
|
|
558
|
+
read from the database unless ``from_db_value()`` reads it its own way.
|
|
559
|
+
|
|
560
|
+
Args:
|
|
561
|
+
value: The value.
|
|
562
|
+
|
|
563
|
+
Returns:
|
|
564
|
+
The value as ``field_type``; None stays None.
|
|
565
|
+
|
|
566
|
+
Raises:
|
|
567
|
+
ValidationError: The value doesn't convert. The exception a malformed value raises
|
|
568
|
+
varies by type - ValueError for int()/float(), TypeError for bytes(str),
|
|
569
|
+
decimal.InvalidOperation for Decimal() - so any is caught and raised as the
|
|
570
|
+
catchable ValidationError every other data-shape failure is.
|
|
571
|
+
"""
|
|
572
|
+
if value is None or isinstance(value, self.field_type):
|
|
573
|
+
return value
|
|
574
|
+
validation_error = None
|
|
575
|
+
try:
|
|
576
|
+
value = self.field_type(value)
|
|
577
|
+
except Exception as error:
|
|
578
|
+
validation_error = self.get_validation_error(error, value)
|
|
579
|
+
if validation_error is not None:
|
|
580
|
+
raise validation_error
|
|
581
|
+
return value
|
|
582
|
+
|
|
583
|
+
def get_read_codec_specification(
|
|
584
|
+
self, types: TypeRegistry, zone_name: str | None
|
|
585
|
+
) -> tuple[str, dict[str, Any]] | None:
|
|
586
|
+
"""The ``rust.native.rows`` codec reading a column of this field, for a field that reads its
|
|
587
|
+
values in a way of its own the codec repeats exactly - a container of other fields' values.
|
|
588
|
+
|
|
589
|
+
Args:
|
|
590
|
+
types: The dialect's type registry.
|
|
591
|
+
zone_name: The configured zone under ``use_timezone``, else None.
|
|
592
|
+
|
|
593
|
+
Returns:
|
|
594
|
+
The read codec type and its options; None leaves the column to the codec of the field's
|
|
595
|
+
type, or to ``from_db_value()``.
|
|
596
|
+
"""
|
|
597
|
+
return None
|
|
598
|
+
|
|
599
|
+
def from_db_value(self, value: Any) -> Any:
|
|
600
|
+
"""The field's Python value of a value read from the database - ``to_python()``, unless
|
|
601
|
+
the field stores its value differently from how it holds it (an encrypted token, JSON
|
|
602
|
+
text, microseconds).
|
|
603
|
+
|
|
604
|
+
Args:
|
|
605
|
+
value: The value the driver returned.
|
|
606
|
+
|
|
607
|
+
Returns:
|
|
608
|
+
The Python value.
|
|
609
|
+
"""
|
|
610
|
+
return self.to_python(value)
|
|
611
|
+
|
|
612
|
+
def get_assign_normalized_types(self) -> frozenset[type]:
|
|
613
|
+
"""Returns the exact types whose values ``to_python`` always returns
|
|
614
|
+
unchanged - a default value of one of them skips that call on instance construction.
|
|
615
|
+
|
|
616
|
+
Returns:
|
|
617
|
+
``{field_type}``, or nothing when ``field_type`` isn't a single class.
|
|
618
|
+
"""
|
|
619
|
+
return frozenset({self.field_type}) if isinstance(self.field_type, type) else frozenset()
|
|
620
|
+
|
|
621
|
+
def get_default_value_on_assign(self, value: Any) -> Any:
|
|
622
|
+
"""Normalizes a callable default's result the way an assigned value is, so memory holds
|
|
623
|
+
the same type a later read returns.
|
|
624
|
+
|
|
625
|
+
Args:
|
|
626
|
+
value: The default value.
|
|
627
|
+
|
|
628
|
+
Returns:
|
|
629
|
+
The normalized value.
|
|
630
|
+
"""
|
|
631
|
+
if self.assign_normalized_types is None:
|
|
632
|
+
self.assign_normalized_types = self.get_assign_normalized_types()
|
|
633
|
+
if value is None or type(value) in self.assign_normalized_types:
|
|
634
|
+
return value
|
|
635
|
+
return self.to_python(value)
|
|
636
|
+
|
|
637
|
+
def get_static_default_value(self) -> Any:
|
|
638
|
+
"""Returns this instance's own copy of the static (non-callable) ``default``, normalized
|
|
639
|
+
the way an assigned value is.
|
|
640
|
+
|
|
641
|
+
Returns:
|
|
642
|
+
The default value.
|
|
643
|
+
"""
|
|
644
|
+
default = self.default
|
|
645
|
+
value = default if isinstance(default, (int, float, str, bool, bytes)) else deepcopy(default)
|
|
646
|
+
if self.static_default_is_normalized is None:
|
|
647
|
+
self.static_default_is_normalized = type(default) in self.get_assign_normalized_types()
|
|
648
|
+
if self.static_default_is_normalized:
|
|
649
|
+
return value
|
|
650
|
+
return self.to_python(value)
|
|
651
|
+
|
|
652
|
+
@classmethod
|
|
653
|
+
def get_native_write_check(cls) -> NativeWriteCheck | None:
|
|
654
|
+
"""The check the ``to_db_value`` in use adds for a value that is exactly ``field_type`` -
|
|
655
|
+
``native_write_check`` of the class that defines that ``to_db_value``.
|
|
656
|
+
|
|
657
|
+
Returns:
|
|
658
|
+
The check; None when ``to_db_value`` is ``Field``'s own, or its class declares no
|
|
659
|
+
``native_write_check`` (its conversion is unknown to the write accelerator).
|
|
660
|
+
"""
|
|
661
|
+
for klass in cls.__mro__:
|
|
662
|
+
if "to_db_value" in klass.__dict__:
|
|
663
|
+
if klass is Field:
|
|
664
|
+
return None
|
|
665
|
+
return cast("NativeWriteCheck | None", klass.__dict__.get("native_write_check"))
|
|
666
|
+
return None
|
|
667
|
+
|
|
668
|
+
def validate(self, value: Any) -> None:
|
|
669
|
+
"""Runs the field's validators on a value - ``None`` passes on a nullable field.
|
|
670
|
+
|
|
671
|
+
Args:
|
|
672
|
+
value: The value.
|
|
673
|
+
|
|
674
|
+
Raises:
|
|
675
|
+
ValidationError: A validator refuses the value.
|
|
676
|
+
"""
|
|
677
|
+
if self.null and value is None:
|
|
678
|
+
return
|
|
679
|
+
if type(value) is self.field_type:
|
|
680
|
+
validators = self.validators
|
|
681
|
+
value_checks = self.value_checks
|
|
682
|
+
if value_checks is None or value_checks[0] is not validators or value_checks[1] != len(validators):
|
|
683
|
+
value_checks = self.value_checks = (validators, len(validators), self._get_native_value_checks())
|
|
684
|
+
if value_checks[2] is not None:
|
|
685
|
+
value_checks[2].check(value, self.model_field_name)
|
|
686
|
+
return
|
|
687
|
+
for validator in self.validators:
|
|
688
|
+
validation_error = None
|
|
689
|
+
try:
|
|
690
|
+
if isinstance(value, Enum):
|
|
691
|
+
validator(value.value)
|
|
692
|
+
else:
|
|
693
|
+
validator(value)
|
|
694
|
+
except Exception as error:
|
|
695
|
+
# A validator may be a plain callable raising anything - wrapped into
|
|
696
|
+
# ValidationError.
|
|
697
|
+
validation_error = self.get_validation_error(error, value)
|
|
698
|
+
if validation_error is not None:
|
|
699
|
+
raise validation_error
|
|
700
|
+
|
|
701
|
+
def get_validated_values(self, values: list[Any]) -> list[Any] | None:
|
|
702
|
+
"""``values`` as ``Field.to_db_value()`` of each gives them, checked in one pass - when every
|
|
703
|
+
one is exactly ``field_type`` and passes the validators.
|
|
704
|
+
|
|
705
|
+
Args:
|
|
706
|
+
values: The values.
|
|
707
|
+
|
|
708
|
+
Returns:
|
|
709
|
+
The values themselves; None when one isn't exactly ``field_type`` or fails a validator -
|
|
710
|
+
converting them one by one then converts them, or raises the first one's error.
|
|
711
|
+
"""
|
|
712
|
+
field_type = self.field_type
|
|
713
|
+
if set(map(type, values)) != {field_type}:
|
|
714
|
+
return None
|
|
715
|
+
# validate()'s own cache of the native checks, read without its per-value call.
|
|
716
|
+
validators = self.validators
|
|
717
|
+
value_checks = self.value_checks
|
|
718
|
+
if value_checks is None or value_checks[0] is not validators or value_checks[1] != len(validators):
|
|
719
|
+
value_checks = self.value_checks = (validators, len(validators), self._get_native_value_checks())
|
|
720
|
+
try:
|
|
721
|
+
if value_checks[2] is not None:
|
|
722
|
+
value_checks[2].check_values(values, self.model_field_name)
|
|
723
|
+
else:
|
|
724
|
+
for value in values:
|
|
725
|
+
self.validate(value)
|
|
726
|
+
except ValidationError:
|
|
727
|
+
return None
|
|
728
|
+
return values
|
|
729
|
+
|
|
730
|
+
def to_db_values(self, values: list[Any], instance: type[Model] | Model | None) -> list[Any]:
|
|
731
|
+
"""``to_db_value()`` of each of ``values`` - checked in one pass when they need no conversion.
|
|
732
|
+
|
|
733
|
+
Args:
|
|
734
|
+
values: The values.
|
|
735
|
+
instance: The model (class) they are written or compared for.
|
|
736
|
+
|
|
737
|
+
Returns:
|
|
738
|
+
The values to bind, in order.
|
|
739
|
+
|
|
740
|
+
Raises:
|
|
741
|
+
ValidationError: The first value ``to_db_value()`` refuses.
|
|
742
|
+
"""
|
|
743
|
+
if type(self).to_db_value is Field.to_db_value:
|
|
744
|
+
validated_values = self.get_validated_values(values)
|
|
745
|
+
if validated_values is not None:
|
|
746
|
+
return validated_values
|
|
747
|
+
return [self.to_db_value(value, instance) for value in values]
|
|
748
|
+
|
|
749
|
+
def to_lookup_values(self, values: list[Any], instance: type[Model] | Model | None) -> list[Any]:
|
|
750
|
+
"""``to_lookup_value()`` of each of ``values`` - a column of key values compared at once.
|
|
751
|
+
|
|
752
|
+
Args:
|
|
753
|
+
values: The values, none of them None.
|
|
754
|
+
instance: The model (class) the filter is built for.
|
|
755
|
+
|
|
756
|
+
Returns:
|
|
757
|
+
The values to bind, in order.
|
|
758
|
+
|
|
759
|
+
Raises:
|
|
760
|
+
ValidationError: The first value ``to_lookup_value()`` refuses.
|
|
761
|
+
"""
|
|
762
|
+
if type(self).to_lookup_value is Field.to_lookup_value:
|
|
763
|
+
return self.to_db_values(values, instance)
|
|
764
|
+
return [self.to_lookup_value(value, instance) for value in values]
|
|
765
|
+
|
|
766
|
+
def _get_native_value_checks(self) -> Any:
|
|
767
|
+
"""The ``rust.native.rows.ValueChecks`` making the validators' checks of a value of exactly
|
|
768
|
+
``field_type`` in one call.
|
|
769
|
+
|
|
770
|
+
Returns:
|
|
771
|
+
The checks; None when a validator checks another way, or its message hides a sensitive
|
|
772
|
+
value.
|
|
773
|
+
"""
|
|
774
|
+
if self.sensitive or not self.validators:
|
|
775
|
+
return None
|
|
776
|
+
# Imported here: hare.query imports the fields package.
|
|
777
|
+
from hare.query.rows.enums import InlineCheckType
|
|
778
|
+
from hare.query.rows.native.field_codecs import FieldCodecs
|
|
779
|
+
from hare.query.rows.native.hydrate_accelerator import HydrateAccelerator
|
|
780
|
+
|
|
781
|
+
value_checks_class = getattr(HydrateAccelerator.module, "ValueChecks", None)
|
|
782
|
+
checks = FieldCodecs.get_inline_checks(self)
|
|
783
|
+
# A codec checks the digits of a value already quantized - validate() gets any value.
|
|
784
|
+
if (
|
|
785
|
+
value_checks_class is None
|
|
786
|
+
or checks is None
|
|
787
|
+
or any(check_type is InlineCheckType.MAX_DIGITS for check_type, _ in checks)
|
|
788
|
+
):
|
|
789
|
+
return None
|
|
790
|
+
return value_checks_class(self.model_field_name, checks)
|
|
791
|
+
|
|
792
|
+
def has_db_default(self) -> bool:
|
|
793
|
+
"""Whether the field declares a ``db_default``."""
|
|
794
|
+
return not isinstance(self.db_default, DbDefaultNotSet)
|
|
795
|
+
|
|
796
|
+
def is_db_default_redundant_with_default(self) -> bool:
|
|
797
|
+
"""Whether a ``db_default`` set alongside ``default`` can never take effect.
|
|
798
|
+
|
|
799
|
+
Returns:
|
|
800
|
+
True for a plain column (``default`` always provides a value before an INSERT); False
|
|
801
|
+
for a field whose ``db_default`` is also read by the database itself outside of an
|
|
802
|
+
INSERT, e.g. a foreign key's ``ON DELETE SET DEFAULT``.
|
|
803
|
+
"""
|
|
804
|
+
return True
|
|
805
|
+
|
|
806
|
+
@staticmethod
|
|
807
|
+
def _is_async_default(default: Any) -> bool:
|
|
808
|
+
"""Whether calling ``default()`` gives an awaitable - an ``async def`` function, possibly in
|
|
809
|
+
``functools.partial``, or an object whose ``__call__`` is one.
|
|
810
|
+
"""
|
|
811
|
+
# Most fields have no default.
|
|
812
|
+
return default is not None and (
|
|
813
|
+
inspect.iscoroutinefunction(default)
|
|
814
|
+
or (callable(default) and inspect.iscoroutinefunction(type(default).__call__))
|
|
815
|
+
)
|
|
816
|
+
|
|
817
|
+
@property
|
|
818
|
+
def required(self) -> bool:
|
|
819
|
+
"""Whether an object must be given the field's value: the field takes no ``None`` and has no
|
|
820
|
+
``default``, no ``db_default`` and no generated value."""
|
|
821
|
+
return self.default is None and not self.null and not self.generated and not self.has_db_default()
|
|
822
|
+
|
|
823
|
+
@classmethod
|
|
824
|
+
@contextlib.contextmanager
|
|
825
|
+
def replaying_migration_scope(cls) -> Generator[None]:
|
|
826
|
+
"""Builds the fields constructed inside the block the way a historical migration file declares them."""
|
|
827
|
+
token = cls.replaying_migration.set(True)
|
|
828
|
+
try:
|
|
829
|
+
yield
|
|
830
|
+
finally:
|
|
831
|
+
cls.replaying_migration.reset(token)
|
|
832
|
+
|
|
833
|
+
def get_db_default_value(self) -> DatabaseDefault | None:
|
|
834
|
+
"""The placeholder of a value left to the field's ``db_default`` - None without one."""
|
|
835
|
+
if self.has_db_default():
|
|
836
|
+
return DatabaseDefault(self)
|
|
837
|
+
return None
|
|
838
|
+
|
|
839
|
+
@property
|
|
840
|
+
def constraints(self) -> dict[str, Any]:
|
|
841
|
+
"""The bounds of the field's values in the pydantic/JSON Schema form (``ge``, ``le``,
|
|
842
|
+
``max_length``) - none by default."""
|
|
843
|
+
return {}
|
|
844
|
+
|
|
845
|
+
def get_lookups(self) -> dict[str, FieldLookup]:
|
|
846
|
+
"""The lookups of the field's type of value, by suffix (``""`` is equality) - the generic set
|
|
847
|
+
by default; a field class with a set of its own overrides it. ``register_lookup()`` lookups
|
|
848
|
+
are added to it.
|
|
849
|
+
|
|
850
|
+
Returns:
|
|
851
|
+
The lookups by suffix.
|
|
852
|
+
"""
|
|
853
|
+
# Local import: the filters package imports the fields package.
|
|
854
|
+
from hare.query.filters.lookups.field_lookups import FieldLookups
|
|
855
|
+
|
|
856
|
+
return FieldLookups.get_generic(self)
|
|
857
|
+
|
|
858
|
+
def get_path_transform(self, segment: str) -> tuple[Callable[[Term], Term], Field[Any]] | None:
|
|
859
|
+
"""How one path segment after the field's name reads inside its value - an array's item
|
|
860
|
+
(``tags__0``) or length (``tags__len``), a range's bound (``during__startswith``) - so a
|
|
861
|
+
lookup (``tags__0__startswith``), ``F()``, ``values()`` and ``order_by()`` can read it.
|
|
862
|
+
|
|
863
|
+
Args:
|
|
864
|
+
segment: The path segment.
|
|
865
|
+
|
|
866
|
+
Returns:
|
|
867
|
+
The function building the term the segment reads from the field's own term, and the
|
|
868
|
+
field of the value it reads; None when the segment reads nothing inside the value.
|
|
869
|
+
"""
|
|
870
|
+
for klass in type(self).__mro__:
|
|
871
|
+
registered_transform = klass.__dict__.get("registered_transforms", {}).get(segment)
|
|
872
|
+
if registered_transform is not None:
|
|
873
|
+
return registered_transform.get_transform(self)
|
|
874
|
+
return None
|
|
875
|
+
|
|
876
|
+
@classmethod
|
|
877
|
+
def register_transform(
|
|
878
|
+
cls,
|
|
879
|
+
segment: str,
|
|
880
|
+
get_transform: Callable[[Field[Any]], tuple[Callable[[Term], Term], Field[Any]]],
|
|
881
|
+
*,
|
|
882
|
+
required_extension: str | None = None,
|
|
883
|
+
) -> None:
|
|
884
|
+
"""Adds a path segment reading inside the value of this field class and its subclasses -
|
|
885
|
+
how a dialect gives field classes it doesn't define one (``unaccent``).
|
|
886
|
+
|
|
887
|
+
Args:
|
|
888
|
+
segment: The path segment.
|
|
889
|
+
get_transform: Builds the transform for one field: the function building the term the
|
|
890
|
+
segment reads, and the field of the value it reads.
|
|
891
|
+
required_extension: The database extension the transform needs.
|
|
892
|
+
"""
|
|
893
|
+
if "registered_transforms" not in cls.__dict__:
|
|
894
|
+
cls.registered_transforms = {}
|
|
895
|
+
cls.registered_transforms[segment] = RegisteredTransform(get_transform, required_extension)
|
|
896
|
+
Registries.changed()
|
|
897
|
+
|
|
898
|
+
def get_lookup_value_description(self, lookup: str) -> tuple[LookupValueShape, Any] | None:
|
|
899
|
+
"""What the filter value of a lookup on this field is, where the field's own lookups take
|
|
900
|
+
something other than a value of the field's type - an array's ``__contains`` takes a list
|
|
901
|
+
of elements, a range's ``__overlap`` a range. ``get_lookup_info()`` reports it.
|
|
902
|
+
|
|
903
|
+
Args:
|
|
904
|
+
lookup: The lookup's name, ``""`` for plain equality.
|
|
905
|
+
|
|
906
|
+
Returns:
|
|
907
|
+
Whether the value is one value, a list or a range, and the type of the value (of each
|
|
908
|
+
item of a list or range); None where the value is described as for any field.
|
|
909
|
+
"""
|
|
910
|
+
return None
|
|
911
|
+
|
|
912
|
+
def get_generated_from_field_names(self) -> tuple[str, ...]:
|
|
913
|
+
"""The model's other fields a generated column is computed from, where the field names them (a
|
|
914
|
+
``TSVectorField``'s ``source_fields``) - a migration refuses to remove one while this field
|
|
915
|
+
reads it, and a rename renames it here.
|
|
916
|
+
|
|
917
|
+
Returns:
|
|
918
|
+
The field names, none by default.
|
|
919
|
+
"""
|
|
920
|
+
return ()
|
|
921
|
+
|
|
922
|
+
def with_renamed_generated_from_field(self, old_name: str, new_name: str) -> Field[Any]:
|
|
923
|
+
"""A copy of the field computed from ``new_name`` wherever it was computed from
|
|
924
|
+
``old_name`` - see ``get_generated_from_field_names()``.
|
|
925
|
+
|
|
926
|
+
Args:
|
|
927
|
+
old_name: The field's old name.
|
|
928
|
+
new_name: The field's new name.
|
|
929
|
+
|
|
930
|
+
Returns:
|
|
931
|
+
The renamed copy, or the field itself when it isn't computed from ``old_name``.
|
|
932
|
+
"""
|
|
933
|
+
return self
|
|
934
|
+
|
|
935
|
+
def get_like_text_function(self) -> Callable[[Term], Term] | None:
|
|
936
|
+
"""How the field's value is turned into text for the LIKE-family lookups (``__contains``,
|
|
937
|
+
``__istartswith``, ...) and the pattern lookups (``__posix_regex``, a dialect's own).
|
|
938
|
+
|
|
939
|
+
Returns:
|
|
940
|
+
The function building the text term from the field's term; None casts the value to
|
|
941
|
+
``VARCHAR``.
|
|
942
|
+
"""
|
|
943
|
+
return None
|
|
944
|
+
|
|
945
|
+
def get_python_type(self) -> Any:
|
|
946
|
+
"""The Python type the field's values have - a relation's related model, a container's element
|
|
947
|
+
type - where ``field_type`` doesn't tell it.
|
|
948
|
+
"""
|
|
949
|
+
return getattr(self, "related_model", self.field_type)
|
|
950
|
+
|
|
951
|
+
def get_value_annotation(self) -> Any:
|
|
952
|
+
"""The Python type of one value of this field: its enum for an enum field, else
|
|
953
|
+
``get_python_type()``."""
|
|
954
|
+
return self.enum_type or self.get_python_type()
|
|
955
|
+
|
|
956
|
+
def get_annotation(self) -> Any:
|
|
957
|
+
"""The annotation of this field's value in a schema - a pydantic model, a framework DTO,
|
|
958
|
+
a request parameter: ``get_value_annotation()``, ``| None`` when the field is nullable."""
|
|
959
|
+
value_annotation = self.get_value_annotation()
|
|
960
|
+
return value_annotation | None if self.null else value_annotation
|
|
961
|
+
|
|
962
|
+
def get_db_field_types(self) -> dict[str, str] | None:
|
|
963
|
+
"""The column type of this field on each dialect.
|
|
964
|
+
|
|
965
|
+
Returns:
|
|
966
|
+
The field's own type under ``""``, plus each registered dialect that stores it
|
|
967
|
+
differently, or None for a field without a column.
|
|
968
|
+
"""
|
|
969
|
+
if not self.has_db_field:
|
|
970
|
+
return None
|
|
971
|
+
default = self.SQL_TYPE
|
|
972
|
+
column_types = {"": default}
|
|
973
|
+
for dialect in DialectRegistry.get_declared_dialects():
|
|
974
|
+
try:
|
|
975
|
+
if not self.exists_on(dialect):
|
|
976
|
+
continue
|
|
977
|
+
column_type = self.get_column_type(dialect)
|
|
978
|
+
except UnSupportedError:
|
|
979
|
+
# A declaration the dialect refuses (a NULL its type can't hold) - no column there; a
|
|
980
|
+
# model of the field bound to that dialect raises it.
|
|
981
|
+
continue
|
|
982
|
+
if column_type != default:
|
|
983
|
+
column_types[dialect.name] = column_type
|
|
984
|
+
return column_types
|
|
985
|
+
|
|
986
|
+
def exists_on(self, dialect: Dialect) -> bool:
|
|
987
|
+
"""Whether the field has a column type on ``dialect``.
|
|
988
|
+
|
|
989
|
+
Args:
|
|
990
|
+
dialect: The dialect.
|
|
991
|
+
|
|
992
|
+
Returns:
|
|
993
|
+
False when the field takes its column type from the dialect (``COLUMN_TYPE_FROM_DIALECT``)
|
|
994
|
+
and the dialect gives none.
|
|
995
|
+
"""
|
|
996
|
+
return not self.COLUMN_TYPE_FROM_DIALECT or dialect.types.get_column_type(self) is not None
|
|
997
|
+
|
|
998
|
+
def get_required_extension(self, dialect: Dialect) -> str | None:
|
|
999
|
+
"""The database extension the field's column needs on ``dialect``.
|
|
1000
|
+
|
|
1001
|
+
Args:
|
|
1002
|
+
dialect: The dialect.
|
|
1003
|
+
|
|
1004
|
+
Returns:
|
|
1005
|
+
The extension the dialect's column type of the field names (``TypeMapping.extension``),
|
|
1006
|
+
None when it needs none or the dialect has no column type of the field.
|
|
1007
|
+
"""
|
|
1008
|
+
return dialect.types.get_extension(self)
|
|
1009
|
+
|
|
1010
|
+
def check_dialect_supported(self, dialect: Dialect) -> None:
|
|
1011
|
+
"""Raises unless the field has a column type on ``dialect``.
|
|
1012
|
+
|
|
1013
|
+
Args:
|
|
1014
|
+
dialect: The dialect.
|
|
1015
|
+
|
|
1016
|
+
Raises:
|
|
1017
|
+
UnSupportedError: The field only exists on other dialects.
|
|
1018
|
+
"""
|
|
1019
|
+
if not self.exists_on(dialect):
|
|
1020
|
+
# An expression's output field has no name of its own.
|
|
1021
|
+
named = f" field '{self.model_field_name}'" if self.model_field_name else ""
|
|
1022
|
+
dialect_names = sorted(
|
|
1023
|
+
str(declared_dialect.name)
|
|
1024
|
+
for declared_dialect in DialectRegistry.get_declared_dialects()
|
|
1025
|
+
if declared_dialect.types.get_column_type(self) is not None
|
|
1026
|
+
)
|
|
1027
|
+
supported = f" only exists on {', '.join(dialect_names)} -" if dialect_names else ":"
|
|
1028
|
+
raise UnSupportedError(
|
|
1029
|
+
f"{type(self).__name__}{named}{supported} the {dialect} dialect has no column type for it."
|
|
1030
|
+
)
|
|
1031
|
+
|
|
1032
|
+
def raise_if_unsupported_by(self, connection: DatabaseClient) -> None:
|
|
1033
|
+
"""Rejects a lookup of the field that needs a connection feature the connection has, but
|
|
1034
|
+
not for this field's settings - nothing by default.
|
|
1035
|
+
|
|
1036
|
+
Args:
|
|
1037
|
+
connection: The connection the query runs on.
|
|
1038
|
+
"""
|
|
1039
|
+
|
|
1040
|
+
def get_column_type(self, dialect: Dialect) -> str:
|
|
1041
|
+
"""The column type of this field on ``dialect``.
|
|
1042
|
+
|
|
1043
|
+
Args:
|
|
1044
|
+
dialect: The dialect.
|
|
1045
|
+
|
|
1046
|
+
Returns:
|
|
1047
|
+
The type.
|
|
1048
|
+
|
|
1049
|
+
Raises:
|
|
1050
|
+
UnSupportedError: The field only exists on other dialects.
|
|
1051
|
+
"""
|
|
1052
|
+
self.check_dialect_supported(dialect)
|
|
1053
|
+
column_type = dialect.types.get_column_type(self)
|
|
1054
|
+
return column_type if column_type is not None else self.SQL_TYPE
|
|
1055
|
+
|
|
1056
|
+
def get_generated_sql(self, dialect: Dialect) -> str | None:
|
|
1057
|
+
"""The DDL that makes the database generate this field's column on ``dialect``.
|
|
1058
|
+
|
|
1059
|
+
Args:
|
|
1060
|
+
dialect: The dialect.
|
|
1061
|
+
|
|
1062
|
+
Returns:
|
|
1063
|
+
The DDL, or None when the field has none.
|
|
1064
|
+
"""
|
|
1065
|
+
generated_sql = dialect.types.get_generated_sql(self)
|
|
1066
|
+
return generated_sql if generated_sql is not None else self.GENERATED_SQL
|
|
1067
|
+
|
|
1068
|
+
def get_generated_column_sql(self, dialect: Dialect) -> str | None:
|
|
1069
|
+
"""The generation clause for this field's non-primary-key generated column.
|
|
1070
|
+
|
|
1071
|
+
Args:
|
|
1072
|
+
dialect: The dialect.
|
|
1073
|
+
|
|
1074
|
+
Returns:
|
|
1075
|
+
The clause, or None when the field has none.
|
|
1076
|
+
|
|
1077
|
+
Raises:
|
|
1078
|
+
ConfigurationError: If the class's generated SQL only defines a primary key.
|
|
1079
|
+
"""
|
|
1080
|
+
if self.generated_requires_primary_key:
|
|
1081
|
+
raise ConfigurationError(
|
|
1082
|
+
f"Field {self.model_field_name!r} ({self.__class__.__name__}) is DB-generated outside the "
|
|
1083
|
+
"primary key - hare can only create such a column as an auto-increment primary key. Map an "
|
|
1084
|
+
"existing generated column (e.g. an IDENTITY column) on a Meta.managed = False model"
|
|
1085
|
+
)
|
|
1086
|
+
return self.get_generated_sql(dialect)
|
|
1087
|
+
|
|
1088
|
+
def get_stored_value_conversion(self, old_field: Field[Any]) -> Callable[[Any], Any] | None:
|
|
1089
|
+
"""How a value stored under ``old_field``'s definition becomes one stored under this one,
|
|
1090
|
+
for a change of the field the column itself doesn't make - an ``AlterField`` rewrites every
|
|
1091
|
+
stored value with it.
|
|
1092
|
+
|
|
1093
|
+
Args:
|
|
1094
|
+
old_field: The field's definition the stored values were written with.
|
|
1095
|
+
|
|
1096
|
+
Returns:
|
|
1097
|
+
The conversion of one stored value, None when the values are stored the same way.
|
|
1098
|
+
"""
|
|
1099
|
+
return None
|
|
1100
|
+
|
|
1101
|
+
def get_function_cast(self, dialect: Dialect) -> Callable[[Field[Any], Term], Term] | None:
|
|
1102
|
+
"""The cast ``dialect`` wraps this field's column in wherever it is compared or ordered.
|
|
1103
|
+
|
|
1104
|
+
Args:
|
|
1105
|
+
dialect: The dialect.
|
|
1106
|
+
|
|
1107
|
+
Returns:
|
|
1108
|
+
A ``(field, term) -> term`` cast, or None.
|
|
1109
|
+
"""
|
|
1110
|
+
return dialect.types.get_function_cast(self)
|
|
1111
|
+
|
|
1112
|
+
def get_narrowing_limit(self, old_field: Field[Any]) -> NarrowingLimit | None:
|
|
1113
|
+
"""What the stored values must fit when an ``AlterField`` turns ``old_field`` into this field -
|
|
1114
|
+
a value beyond it would be truncated or rounded. Overridden by field types with a
|
|
1115
|
+
size-bounded column.
|
|
1116
|
+
|
|
1117
|
+
Args:
|
|
1118
|
+
old_field: The previous definition.
|
|
1119
|
+
|
|
1120
|
+
Returns:
|
|
1121
|
+
The limit, None if the change never narrows.
|
|
1122
|
+
"""
|
|
1123
|
+
return None
|
|
1124
|
+
|
|
1125
|
+
@classmethod
|
|
1126
|
+
def _get_constructor_parameters(cls) -> tuple[tuple[str, Any], ...]:
|
|
1127
|
+
"""The parameters of the class's constructor and their defaults - read off its signature
|
|
1128
|
+
once per class.
|
|
1129
|
+
|
|
1130
|
+
Returns:
|
|
1131
|
+
Each parameter's name and default, ``inspect.Parameter.empty`` for none.
|
|
1132
|
+
"""
|
|
1133
|
+
key = (cls,)
|
|
1134
|
+
parameters = Field.constructor_parameters.get(key)
|
|
1135
|
+
if parameters is None:
|
|
1136
|
+
parameters = Field.constructor_parameters[key] = tuple(
|
|
1137
|
+
(name, parameter.default) for name, parameter in inspect.signature(cls.__init__).parameters.items()
|
|
1138
|
+
)
|
|
1139
|
+
return parameters
|
|
1140
|
+
|
|
1141
|
+
def deconstruct(self) -> tuple[str, list[Any], dict[str, Any]]:
|
|
1142
|
+
"""The call rebuilding the field - what a migration writes.
|
|
1143
|
+
|
|
1144
|
+
Returns:
|
|
1145
|
+
The class's import path, the positional arguments and the keyword arguments.
|
|
1146
|
+
"""
|
|
1147
|
+
# migration_import_path lets a custom Field class pin a "stable" import path - without
|
|
1148
|
+
# this, moving the class to another module silently breaks ALREADY-generated migrations
|
|
1149
|
+
# (which otherwise embed `__module__`, accurate only at generation time).
|
|
1150
|
+
path = getattr(self.__class__, "migration_import_path", None) or (ClassPath.get(self.__class__))
|
|
1151
|
+
kwargs = self._get_common_constructor_arguments()
|
|
1152
|
+
# The class's own arguments (max_length, the related model) come first, like the
|
|
1153
|
+
# constructor call they describe.
|
|
1154
|
+
return path, [], {**self._get_class_constructor_arguments(kwargs), **kwargs}
|
|
1155
|
+
|
|
1156
|
+
def _get_common_constructor_arguments(self) -> dict[str, Any]:
|
|
1157
|
+
"""The arguments every field takes that this one is given other than by default.
|
|
1158
|
+
|
|
1159
|
+
Returns:
|
|
1160
|
+
The arguments by name.
|
|
1161
|
+
"""
|
|
1162
|
+
kwargs: dict[str, Any] = {}
|
|
1163
|
+
if self.source_field:
|
|
1164
|
+
kwargs["source_field"] = self.source_field
|
|
1165
|
+
if self.generated:
|
|
1166
|
+
kwargs["generated"] = self.generated
|
|
1167
|
+
if self.pk:
|
|
1168
|
+
kwargs["primary_key"] = self.pk
|
|
1169
|
+
if self.null:
|
|
1170
|
+
kwargs["null"] = self.null
|
|
1171
|
+
if self.default is not None:
|
|
1172
|
+
kwargs["default"] = self.default
|
|
1173
|
+
# A primary key is unique and indexed by itself.
|
|
1174
|
+
implied_by_primary_key = self.pk and self.indexable
|
|
1175
|
+
if self.unique and not implied_by_primary_key:
|
|
1176
|
+
kwargs["unique"] = self.unique
|
|
1177
|
+
if self.index and not implied_by_primary_key:
|
|
1178
|
+
kwargs["db_index"] = self.index
|
|
1179
|
+
if self.description is not None:
|
|
1180
|
+
kwargs["description"] = self.description
|
|
1181
|
+
if getattr(self, "db_constraint", True) is False:
|
|
1182
|
+
kwargs["db_constraint"] = False
|
|
1183
|
+
if hasattr(self, "to_field") and getattr(self, "to_field") is not None:
|
|
1184
|
+
kwargs["to_field"] = getattr(self, "to_field")
|
|
1185
|
+
if self.has_db_default():
|
|
1186
|
+
kwargs["db_default"] = self.db_default
|
|
1187
|
+
return kwargs
|
|
1188
|
+
|
|
1189
|
+
def _get_class_constructor_arguments(self, common_kwargs: dict[str, Any]) -> dict[str, Any]:
|
|
1190
|
+
"""The arguments of the field's own class it is given other than by default.
|
|
1191
|
+
|
|
1192
|
+
Args:
|
|
1193
|
+
common_kwargs: The arguments every field takes - not repeated.
|
|
1194
|
+
|
|
1195
|
+
Returns:
|
|
1196
|
+
The arguments by name.
|
|
1197
|
+
"""
|
|
1198
|
+
class_kwargs: dict[str, Any] = {}
|
|
1199
|
+
for name, default in self._get_constructor_parameters():
|
|
1200
|
+
if name in UNWRITTEN_FIELD_CONSTRUCTOR_PARAMETERS or name in self.unwritten_constructor_parameters:
|
|
1201
|
+
continue
|
|
1202
|
+
if name in common_kwargs or not hasattr(self, name):
|
|
1203
|
+
continue
|
|
1204
|
+
value = self._get_constructor_argument_value(name)
|
|
1205
|
+
# A value the constructor takes by default needn't be written.
|
|
1206
|
+
if default is not inspect.Parameter.empty and value == default:
|
|
1207
|
+
continue
|
|
1208
|
+
class_kwargs[name] = value
|
|
1209
|
+
return class_kwargs
|
|
1210
|
+
|
|
1211
|
+
def _get_constructor_argument_value(self, name: str) -> Any:
|
|
1212
|
+
"""The value of one of the field's own constructor arguments - a related model by its label,
|
|
1213
|
+
a through model as it was declared.
|
|
1214
|
+
|
|
1215
|
+
Args:
|
|
1216
|
+
name: The argument.
|
|
1217
|
+
|
|
1218
|
+
Returns:
|
|
1219
|
+
The value.
|
|
1220
|
+
"""
|
|
1221
|
+
value = getattr(self, name)
|
|
1222
|
+
if name == "model_name" and value is not None and not isinstance(value, str) and hasattr(value, "_meta"):
|
|
1223
|
+
return f"{value._meta.app}.{value.__name__}"
|
|
1224
|
+
if name == "through" and getattr(self, "through_model", None) is not None:
|
|
1225
|
+
# The declared through model, not the resolved table name, is written - a replay must
|
|
1226
|
+
# see a through model again.
|
|
1227
|
+
through_model = self.through_model # type: ignore[attr-defined]
|
|
1228
|
+
if isinstance(through_model, (str, SwappableModelReference)):
|
|
1229
|
+
return through_model
|
|
1230
|
+
return f"{through_model._meta.app}.{through_model.__name__}"
|
|
1231
|
+
return value
|