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
|
@@ -0,0 +1,1012 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Awaitable, Callable, Generator, Iterable, Sequence
|
|
4
|
+
from itertools import chain, compress, repeat
|
|
5
|
+
from operator import attrgetter, not_
|
|
6
|
+
from typing import TYPE_CHECKING, Any, Generic, TypeVar, cast
|
|
7
|
+
|
|
8
|
+
from hare.exceptions import QueryError, StaleObjectError, ValidationError
|
|
9
|
+
from hare.fields.relations.fields.foreign_key_field_instance import ForeignKeyFieldInstance
|
|
10
|
+
from hare.fields.relations.fields.one_to_one_field_instance import OneToOneFieldInstance
|
|
11
|
+
from hare.instrumentation.capture.captured_write import CapturedWrite
|
|
12
|
+
from hare.instrumentation.change_events import ChangeEvents
|
|
13
|
+
from hare.instrumentation.enums import RowOperation
|
|
14
|
+
from hare.models.instances.dirty_fields import DirtyFields
|
|
15
|
+
from hare.models.instances.instance_saving import InstanceSaving
|
|
16
|
+
from hare.models.tenancy.tenancy import Tenancy
|
|
17
|
+
from hare.models.write.instance_capture import InstanceCapture
|
|
18
|
+
from hare.models.write.instance_values import InstanceValues
|
|
19
|
+
from hare.models.write.returned_values import ReturnedValues
|
|
20
|
+
from hare.models.write.rules.constants import BULK_UPDATE_METHOD_NAME
|
|
21
|
+
from hare.models.write.rules.enums import WriteType
|
|
22
|
+
from hare.models.write.rules.row_write_rules import RowWriteRules
|
|
23
|
+
from hare.models.write.rules.tenant_write_rules import TenantWriteRules
|
|
24
|
+
from hare.models.write.rules.written_target_checks import WrittenTargetChecks
|
|
25
|
+
from hare.models.write.write_steps import WriteSteps
|
|
26
|
+
from hare.query.expressions import Q
|
|
27
|
+
from hare.query.queryset.arguments.collection_arguments import CollectionArguments
|
|
28
|
+
from hare.query.rows.native.hydrate_accelerator import HydrateAccelerator
|
|
29
|
+
from hare.query.rows.values_rows.value_field import ValueField
|
|
30
|
+
from hare.query.scopes.tenants.tenant_scope import TenantScope
|
|
31
|
+
from hare.query.statements.building.query_conditions import QueryConditions
|
|
32
|
+
from hare.query.statements.building.query_ctes import QueryCtes
|
|
33
|
+
from hare.query.statements.building.query_grouping import QueryGrouping
|
|
34
|
+
from hare.query.statements.building.query_joins import QueryJoins
|
|
35
|
+
from hare.query.statements.constants import BULK_UPDATE_MATCHES_FILTER_ALIAS, BULK_UPDATE_VALUES_ALIAS
|
|
36
|
+
from hare.query.statements.write.bulk.bulk_objects import BulkObjects
|
|
37
|
+
from hare.query.statements.write.bulk.bulk_update_checks import BulkUpdateChecks
|
|
38
|
+
from hare.query.statements.write.bulk.bulk_write_batches import BulkWriteBatches
|
|
39
|
+
from hare.query.statements.write.bulk.declarations import BulkUpdateStatementLayout
|
|
40
|
+
from hare.query.statements.write.update_query import UpdateQuery
|
|
41
|
+
from hare.sql.builder.queries.query_sql_rendering import QuerySqlRendering
|
|
42
|
+
from hare.sql.builder.returned_value import ReturnedValue
|
|
43
|
+
from hare.sql.functions.cast import Cast
|
|
44
|
+
from hare.sql.terms.case.case import Case
|
|
45
|
+
from hare.sql.terms.parameters.parameterizer import Parameterizer
|
|
46
|
+
from hare.sql.terms.parameters.query_parameters import QueryParameters
|
|
47
|
+
from hare.sql.terms.term import Term
|
|
48
|
+
from hare.sql.terms.tuple import Tuple
|
|
49
|
+
from hare.sql.terms.values.literal_value import LiteralValue
|
|
50
|
+
from hare.sql.terms.values.row_value_list import RowValueList
|
|
51
|
+
|
|
52
|
+
if TYPE_CHECKING:
|
|
53
|
+
from hare.dialects.base.types.type_registry import TypeRegistry
|
|
54
|
+
from hare.fields.field import Field
|
|
55
|
+
from hare.instrumentation.capture.capture_needs import CaptureNeeds
|
|
56
|
+
from hare.models import Model
|
|
57
|
+
from hare.query.queryset.queryset import QuerySet
|
|
58
|
+
from hare.sql.builder.tables.table import Table
|
|
59
|
+
from hare.sql.sql_context import SqlContext
|
|
60
|
+
|
|
61
|
+
TModel = TypeVar("TModel", bound="Model")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class BulkUpdateQuery(UpdateQuery, Generic[TModel]):
|
|
65
|
+
"""``queryset.bulk_update()`` - the given fields of each object written to its row, by batches."""
|
|
66
|
+
|
|
67
|
+
__slots__ = (
|
|
68
|
+
"fields",
|
|
69
|
+
"_objects",
|
|
70
|
+
"_batch_size",
|
|
71
|
+
"_returning",
|
|
72
|
+
"_filter_criterion",
|
|
73
|
+
"_tenant_scoped",
|
|
74
|
+
"_unwritten_objects",
|
|
75
|
+
"_completed_objects",
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
def __init__(
|
|
79
|
+
self,
|
|
80
|
+
source: QuerySet[Any, Any],
|
|
81
|
+
objects: Iterable[TModel],
|
|
82
|
+
fields: Iterable[str],
|
|
83
|
+
batch_size: int | None = None,
|
|
84
|
+
returning: bool | None = None,
|
|
85
|
+
):
|
|
86
|
+
"""
|
|
87
|
+
Args:
|
|
88
|
+
source: The queryset whose rows the objects are written among.
|
|
89
|
+
objects: The instances to write.
|
|
90
|
+
fields: The fields to write.
|
|
91
|
+
batch_size: How many instances one statement writes.
|
|
92
|
+
returning: Read the written rows back into the instances - ``Meta.returning`` when None.
|
|
93
|
+
|
|
94
|
+
Raises:
|
|
95
|
+
QueryError: An object or a field can't be written by ``bulk_update()``.
|
|
96
|
+
IncompleteInstanceError: A partially loaded object lacks a field the update reads.
|
|
97
|
+
FieldError: A name in ``fields`` isn't a field of the model.
|
|
98
|
+
"""
|
|
99
|
+
BulkWriteBatches.check_batch_size(batch_size, "bulk_update")
|
|
100
|
+
WrittenTargetChecks.raise_if_refused(source, "bulk_update")
|
|
101
|
+
model = source.model
|
|
102
|
+
returning = model._meta.returning if returning is None else returning
|
|
103
|
+
objects = CollectionArguments.get_list(objects, "bulk_update()")
|
|
104
|
+
field_names = CollectionArguments.get_list(fields, f"bulk_update() on {model.__name__}: fields")
|
|
105
|
+
if not field_names:
|
|
106
|
+
raise QueryError(f"bulk_update() on {model.__name__} needs at least one field to update")
|
|
107
|
+
rules = RowWriteRules.get(model, WriteType.UPDATE, field_names, BULK_UPDATE_METHOD_NAME)
|
|
108
|
+
named_field_names = cast("tuple[str, ...]", rules.named_field_names)
|
|
109
|
+
BulkObjects.validate(
|
|
110
|
+
model, objects, "bulk_update", [*named_field_names, *model._meta.primary_key_attribute_names]
|
|
111
|
+
)
|
|
112
|
+
tenant_scoped = bool(model._meta.tenant_field) and not source._visibility.all_tenants
|
|
113
|
+
if tenant_scoped:
|
|
114
|
+
BulkUpdateChecks.check_tenant_values_resolved(model, objects)
|
|
115
|
+
BulkUpdateChecks.check_primary_keys(model, objects)
|
|
116
|
+
if source._uses_default_scope:
|
|
117
|
+
# The objects are matched by their keys, like save() matches one: under the default
|
|
118
|
+
# scope a soft-deleted object would match no row. Their tenant is checked above.
|
|
119
|
+
source = source._clone()
|
|
120
|
+
source._uses_default_scope = False
|
|
121
|
+
super().__init__(source, {})
|
|
122
|
+
#: What the update writes - the fields named, the blind indexes and the stamps.
|
|
123
|
+
self._rules = rules
|
|
124
|
+
self.fields = rules.get_written_names()
|
|
125
|
+
self._objects = objects
|
|
126
|
+
self._batch_size = batch_size
|
|
127
|
+
self._returning = returning
|
|
128
|
+
# Whether the rows belong to the tenant active when the query runs (Meta.tenant_field set,
|
|
129
|
+
# no .all_tenants()).
|
|
130
|
+
self._tenant_scoped = tenant_scoped
|
|
131
|
+
# The queryset's own filter as a criterion over the base table alone, set by
|
|
132
|
+
# _make_queries() - None when the queryset carries no filter.
|
|
133
|
+
self._filter_criterion: Term | None = None
|
|
134
|
+
# The objects whose row the run didn't write (a stale version, a row gone) - neither reported
|
|
135
|
+
# nor captured.
|
|
136
|
+
self._unwritten_objects: list[TModel] = []
|
|
137
|
+
# The objects of the statements that ran to the end - all a failed call of explicit batches
|
|
138
|
+
# left written.
|
|
139
|
+
self._completed_objects: list[TModel] = []
|
|
140
|
+
|
|
141
|
+
@staticmethod
|
|
142
|
+
def _pk_and_version_db_values(
|
|
143
|
+
types: TypeRegistry,
|
|
144
|
+
obj: TModel,
|
|
145
|
+
pk_values: tuple[Any, ...],
|
|
146
|
+
pk_field_objs: list[Any],
|
|
147
|
+
optimistic_lock_field_obj: Any,
|
|
148
|
+
optimistic_lock_field: str | None,
|
|
149
|
+
) -> list[Any]:
|
|
150
|
+
"""The DB values of an object's primary key column(s), then the optimistic lock column's old
|
|
151
|
+
value when the model has one - the column order of a VALUES row.
|
|
152
|
+
"""
|
|
153
|
+
db_values = [
|
|
154
|
+
types.get_db_value(pk_field_obj, pk_value, None)
|
|
155
|
+
for pk_value, pk_field_obj in zip(pk_values, pk_field_objs, strict=True)
|
|
156
|
+
]
|
|
157
|
+
if optimistic_lock_field_obj is not None and optimistic_lock_field is not None:
|
|
158
|
+
db_values.append(types.get_db_value(optimistic_lock_field_obj, getattr(obj, optimistic_lock_field), obj))
|
|
159
|
+
return db_values
|
|
160
|
+
|
|
161
|
+
def _make_queries(self, parameters_inline: bool = False) -> list[tuple[str, list[Any], list[TModel]]]:
|
|
162
|
+
"""One UPDATE over a VALUES table of the rows per batch of objects - a single pass, instead of
|
|
163
|
+
a CASE per field. One multi-row UPDATE per batch is one round trip.
|
|
164
|
+
|
|
165
|
+
Args:
|
|
166
|
+
parameters_inline: Write every value into the SQL text instead of binding it.
|
|
167
|
+
|
|
168
|
+
Returns:
|
|
169
|
+
Each statement, its parameters and the objects it writes.
|
|
170
|
+
|
|
171
|
+
Raises:
|
|
172
|
+
UnSupportedError: A field is a key column the database doesn't update in place.
|
|
173
|
+
"""
|
|
174
|
+
table_options = self.model._meta.get_table_options(self.dialect)
|
|
175
|
+
if table_options is not None:
|
|
176
|
+
table_options.raise_if_fixed_fields_written(self.model, self.fields)
|
|
177
|
+
layout = self._get_statement_layout(parameters_inline=parameters_inline)
|
|
178
|
+
queries_with_parameters: list[tuple[str, list[Any], list[TModel]]] = []
|
|
179
|
+
for batch in BulkWriteBatches.get_batches(self._objects, layout.batch_size):
|
|
180
|
+
objects_item = list(batch)
|
|
181
|
+
if not objects_item:
|
|
182
|
+
continue
|
|
183
|
+
if not parameters_inline:
|
|
184
|
+
queries_with_parameters.append(self._make_whole_rows_query(layout, objects_item))
|
|
185
|
+
else:
|
|
186
|
+
queries_with_parameters.append(
|
|
187
|
+
self._make_query_by_value(layout, objects_item, parameters_inline=parameters_inline)
|
|
188
|
+
)
|
|
189
|
+
return queries_with_parameters
|
|
190
|
+
|
|
191
|
+
def _get_filter_criterion(self, table: Table) -> Term | None:
|
|
192
|
+
"""The queryset's own filter as a criterion over the base table alone - through a primary
|
|
193
|
+
key subquery where it needs a JOIN, which the hand-built ``UPDATE ... FROM (VALUES ...)``
|
|
194
|
+
can't carry. The query's CTEs are applied after it, so the WITH clause is rendered once,
|
|
195
|
+
ahead of the UPDATE, rather than inside that subquery too.
|
|
196
|
+
|
|
197
|
+
Args:
|
|
198
|
+
table: The model's table.
|
|
199
|
+
|
|
200
|
+
Returns:
|
|
201
|
+
The criterion, None when the queryset carries no filter.
|
|
202
|
+
"""
|
|
203
|
+
# Reset first: a rebuild would take every join as already made.
|
|
204
|
+
QueryJoins.reset_joined_tables(self)
|
|
205
|
+
# Built as a SELECT first: QueryConditions.get_filters() needs somewhere to attach a JOIN.
|
|
206
|
+
self._apply_ambient_scope()
|
|
207
|
+
self.query = self._get_base_query()
|
|
208
|
+
QueryConditions.get_filters(self)
|
|
209
|
+
# A filter on an aggregate annotation needs its GROUP BY to be applied per row.
|
|
210
|
+
QueryGrouping.apply_auto_group_by(self)
|
|
211
|
+
if self._filters_need_primary_key_subquery():
|
|
212
|
+
pk_fields_for_subquery = [
|
|
213
|
+
table[self.model._meta.fields_map[name].source_field or name]
|
|
214
|
+
for name in self.model._meta.primary_key_attribute_names
|
|
215
|
+
]
|
|
216
|
+
# The annotation terms QueryConditions.get_filters() selected would become extra subquery columns.
|
|
217
|
+
self.query._selects = []
|
|
218
|
+
subquery = self.query.select(*pk_fields_for_subquery)
|
|
219
|
+
pk_reference = (
|
|
220
|
+
pk_fields_for_subquery[0] if len(pk_fields_for_subquery) == 1 else Tuple(*pk_fields_for_subquery)
|
|
221
|
+
)
|
|
222
|
+
filter_criterion: Term | None = pk_reference.isin(subquery)
|
|
223
|
+
else:
|
|
224
|
+
filter_criterion = self.query._wheres
|
|
225
|
+
QueryCtes.apply_with_ctes(self)
|
|
226
|
+
return filter_criterion or None
|
|
227
|
+
|
|
228
|
+
def _get_returning_columns(self, pk_columns: list[str]) -> list[str]:
|
|
229
|
+
"""The columns the UPDATE returns: the primary key - the rows come in no order - and, with
|
|
230
|
+
returning=True, the generated columns. The key alone is returned for a model with an
|
|
231
|
+
optimistic lock field, dirty tracking or an updated ``auto_now`` field: only the objects whose
|
|
232
|
+
rows were written get their version, baseline and stamps.
|
|
233
|
+
|
|
234
|
+
Args:
|
|
235
|
+
pk_columns: The primary key's columns.
|
|
236
|
+
|
|
237
|
+
Returns:
|
|
238
|
+
The columns, none when nothing is read back.
|
|
239
|
+
"""
|
|
240
|
+
meta = self.model._meta
|
|
241
|
+
if not self.dialect.features.supports_returning:
|
|
242
|
+
return []
|
|
243
|
+
if self._returning and meta.generated_db_fields:
|
|
244
|
+
return list(dict.fromkeys(pk_columns + list(meta.generated_db_fields)))
|
|
245
|
+
if self._reads_written_keys():
|
|
246
|
+
return list(pk_columns)
|
|
247
|
+
return []
|
|
248
|
+
|
|
249
|
+
def _reads_written_keys(self) -> bool:
|
|
250
|
+
"""Whether the UPDATE returns the keys of the rows it wrote, and nothing else - for a model with
|
|
251
|
+
an optimistic lock field, dirty tracking or an updated ``auto_now`` field.
|
|
252
|
+
|
|
253
|
+
Returns:
|
|
254
|
+
Whether it does.
|
|
255
|
+
"""
|
|
256
|
+
meta = self.model._meta
|
|
257
|
+
# An auto_now field stamped on an instance has to be put back when its row wasn't written.
|
|
258
|
+
has_auto_now_field = any(getattr(meta.fields_map[field_name], "auto_now", False) for field_name in self.fields)
|
|
259
|
+
return bool(meta.optimistic_lock_field or meta.track_dirty_fields or has_auto_now_field)
|
|
260
|
+
|
|
261
|
+
def _get_written_column_fields(self) -> list[str]:
|
|
262
|
+
"""The column fields the UPDATE writes - a relation through its key column field(s), every
|
|
263
|
+
one of them for a composite key; a relation and its own key field named together write the
|
|
264
|
+
column once.
|
|
265
|
+
|
|
266
|
+
Returns:
|
|
267
|
+
The field names.
|
|
268
|
+
"""
|
|
269
|
+
fields: list[str] = []
|
|
270
|
+
for field in self.fields:
|
|
271
|
+
field_object = self.model._meta.fields_map[field]
|
|
272
|
+
if isinstance(field_object, (ForeignKeyFieldInstance, OneToOneFieldInstance)):
|
|
273
|
+
fields.extend(field_object.source_fields)
|
|
274
|
+
else:
|
|
275
|
+
fields.append(field)
|
|
276
|
+
return list(dict.fromkeys(fields))
|
|
277
|
+
|
|
278
|
+
def _get_statement_layout(self, *, parameters_inline: bool) -> BulkUpdateStatementLayout:
|
|
279
|
+
"""What every statement of this call shares.
|
|
280
|
+
|
|
281
|
+
Args:
|
|
282
|
+
parameters_inline: Whether every value is written into the SQL text.
|
|
283
|
+
|
|
284
|
+
Returns:
|
|
285
|
+
The layout.
|
|
286
|
+
"""
|
|
287
|
+
meta = self.model._meta
|
|
288
|
+
table = meta.basetable
|
|
289
|
+
filter_criterion = self._filter_criterion = self._get_filter_criterion(table)
|
|
290
|
+
# One PK column for a regular model, N (in primary_key_attribute order) for a composite one -
|
|
291
|
+
# everything below is written to that general case, a single-column PK is just N=1 of it.
|
|
292
|
+
primary_key_attribute_names = meta.primary_key_attribute_names
|
|
293
|
+
pk_field_objects = [meta.fields_map[name] for name in primary_key_attribute_names]
|
|
294
|
+
pk_columns = [
|
|
295
|
+
field_object.source_field or name
|
|
296
|
+
for field_object, name in zip(pk_field_objects, primary_key_attribute_names, strict=True)
|
|
297
|
+
]
|
|
298
|
+
pk_column_count = len(primary_key_attribute_names)
|
|
299
|
+
fields = self._get_written_column_fields()
|
|
300
|
+
field_objects = [meta.fields_map[field] for field in fields]
|
|
301
|
+
dialect = self._connection.dialect
|
|
302
|
+
get_cast_type = dialect.parameters.get_field_parameter_cast_type
|
|
303
|
+
# A database may not infer a column's type from a VALUES row that mixes types across
|
|
304
|
+
# columns - the dialect names the cast every column needs then, the pk column(s) included.
|
|
305
|
+
field_cast_types = [get_cast_type(field_object) for field_object in field_objects]
|
|
306
|
+
# Optimistic locking: the old version is per object, so it rides in the VALUES row after the
|
|
307
|
+
# key and is matched in WHERE like the key; the bump is the same SET for every row.
|
|
308
|
+
optimistic_lock_field = meta.optimistic_lock_field
|
|
309
|
+
optimistic_lock_field_object = meta.fields_map[optimistic_lock_field] if optimistic_lock_field else None
|
|
310
|
+
get_key_cast_type = dialect.parameters.get_row_key_cast_type
|
|
311
|
+
key_cast_types = [get_key_cast_type(field_object) for field_object in pk_field_objects]
|
|
312
|
+
key_fields = list(primary_key_attribute_names)
|
|
313
|
+
version_column = None
|
|
314
|
+
if optimistic_lock_field_object is not None and optimistic_lock_field:
|
|
315
|
+
version_column = optimistic_lock_field_object.source_field or optimistic_lock_field
|
|
316
|
+
key_cast_types.append(get_key_cast_type(optimistic_lock_field_object))
|
|
317
|
+
key_fields.append(optimistic_lock_field)
|
|
318
|
+
|
|
319
|
+
base_context = self.query.query_class.SQL_CONTEXT
|
|
320
|
+
quote: Callable[[str], str] = base_context.quote
|
|
321
|
+
db_table = meta.db_table
|
|
322
|
+
values_alias = BULK_UPDATE_VALUES_ALIAS
|
|
323
|
+
while values_alias == db_table:
|
|
324
|
+
values_alias += "_"
|
|
325
|
+
values_alias_sql = quote(values_alias)
|
|
326
|
+
# c0..c{key column count - 1} = the key column(s) and the old version, the rest the written
|
|
327
|
+
# fields.
|
|
328
|
+
value_column_names = [f"c{column_position}" for column_position in range(len(key_fields) + len(fields))]
|
|
329
|
+
clauses = self._connection.dialect.clauses
|
|
330
|
+
# Table-qualified on the right-hand side and in WHERE, so a model column named like one of
|
|
331
|
+
# the VALUES table's own c<N> columns can't be read from the wrong side.
|
|
332
|
+
table_sql = quote(db_table)
|
|
333
|
+
assignments = [
|
|
334
|
+
(quote(field_object.source_field or field), f"{values_alias_sql}.{value_column_name}")
|
|
335
|
+
for field_object, field, value_column_name in zip(
|
|
336
|
+
field_objects, fields, value_column_names[len(key_fields) :], strict=True
|
|
337
|
+
)
|
|
338
|
+
]
|
|
339
|
+
matches = [
|
|
340
|
+
(f"{table_sql}.{quote(column)}", f"{values_alias_sql}.{value_column_name}")
|
|
341
|
+
for column, value_column_name in zip(
|
|
342
|
+
[*pk_columns, *([version_column] if version_column is not None else [])],
|
|
343
|
+
value_column_names,
|
|
344
|
+
strict=False,
|
|
345
|
+
)
|
|
346
|
+
]
|
|
347
|
+
if version_column is not None:
|
|
348
|
+
assignments.append((quote(version_column), f"{table_sql}.{quote(version_column)} + 1"))
|
|
349
|
+
# A value's placeholder depends only on the dialect and the cast type - one template per
|
|
350
|
+
# column, formatted with the parameter index, instead of a Parameter and Cast term per value.
|
|
351
|
+
placeholder_template = dialect.parameters.placeholder_template
|
|
352
|
+
key_placeholder_templates = [
|
|
353
|
+
clauses.get_typed_placeholder_template(placeholder_template, cast_type) for cast_type in key_cast_types
|
|
354
|
+
]
|
|
355
|
+
field_placeholder_templates = [
|
|
356
|
+
clauses.get_typed_placeholder_template(placeholder_template, cast_type) for cast_type in field_cast_types
|
|
357
|
+
]
|
|
358
|
+
# Inlined SQL binds nothing, so only the parameterized path is limited by the bind-parameter
|
|
359
|
+
# ceiling - less what every statement binds besides its rows.
|
|
360
|
+
batch_size = (
|
|
361
|
+
self._batch_size
|
|
362
|
+
if parameters_inline
|
|
363
|
+
else BulkWriteBatches.get_bind_parameter_safe_batch_size(
|
|
364
|
+
self._batch_size,
|
|
365
|
+
len(value_column_names),
|
|
366
|
+
self.features.max_bind_parameters - self._get_fixed_parameter_count(base_context, filter_criterion),
|
|
367
|
+
)
|
|
368
|
+
)
|
|
369
|
+
if (max_rows := self.features.max_bulk_update_rows) is not None:
|
|
370
|
+
batch_size = max_rows if batch_size is None else min(batch_size, max_rows)
|
|
371
|
+
return BulkUpdateStatementLayout(
|
|
372
|
+
table=table,
|
|
373
|
+
base_context=base_context,
|
|
374
|
+
filter_criterion=filter_criterion,
|
|
375
|
+
assignments=assignments,
|
|
376
|
+
matches=matches,
|
|
377
|
+
returned=[
|
|
378
|
+
ReturnedValue(sql=f"{table_sql}.{quote(column)}", alias_sql=quote(column))
|
|
379
|
+
for column in self._get_returning_columns(pk_columns)
|
|
380
|
+
],
|
|
381
|
+
values_columns_sql=clauses.get_values_table_columns_sql(value_column_names),
|
|
382
|
+
values_alias_sql=values_alias_sql,
|
|
383
|
+
fields=fields,
|
|
384
|
+
field_cast_types=field_cast_types,
|
|
385
|
+
field_placeholder_templates=field_placeholder_templates,
|
|
386
|
+
pk_column_count=pk_column_count,
|
|
387
|
+
pk_field_objects=pk_field_objects,
|
|
388
|
+
optimistic_lock_field=optimistic_lock_field if version_column is not None else None,
|
|
389
|
+
optimistic_lock_field_object=optimistic_lock_field_object if version_column is not None else None,
|
|
390
|
+
key_cast_types=key_cast_types,
|
|
391
|
+
key_placeholder_templates=key_placeholder_templates,
|
|
392
|
+
row_fields=[*key_fields, *fields],
|
|
393
|
+
row_placeholder_templates=tuple(key_placeholder_templates + field_placeholder_templates),
|
|
394
|
+
batch_size=batch_size,
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
def _get_update_sql(
|
|
398
|
+
self, layout: BulkUpdateStatementLayout, values_context: SqlContext, with_sql: str, values_sql: str
|
|
399
|
+
) -> str:
|
|
400
|
+
"""The UPDATE of one batch.
|
|
401
|
+
|
|
402
|
+
Args:
|
|
403
|
+
layout: What every statement of this call shares.
|
|
404
|
+
values_context: The context the batch's values render in.
|
|
405
|
+
with_sql: The WITH clause.
|
|
406
|
+
values_sql: The VALUES rows.
|
|
407
|
+
|
|
408
|
+
Returns:
|
|
409
|
+
The statement.
|
|
410
|
+
"""
|
|
411
|
+
filter_criterion = layout.filter_criterion
|
|
412
|
+
return self._connection.dialect.clauses.get_update_from_values_sql(
|
|
413
|
+
with_sql=with_sql,
|
|
414
|
+
table=layout.table,
|
|
415
|
+
table_sql=layout.table.get_sql(layout.base_context),
|
|
416
|
+
assignments=layout.assignments,
|
|
417
|
+
values_columns_sql=layout.values_columns_sql,
|
|
418
|
+
values_sql=values_sql,
|
|
419
|
+
values_alias_sql=layout.values_alias_sql,
|
|
420
|
+
matches=layout.matches,
|
|
421
|
+
condition_sql=(
|
|
422
|
+
filter_criterion.get_sql(values_context.copy(subquery=True, with_namespace=True))
|
|
423
|
+
if filter_criterion
|
|
424
|
+
else None
|
|
425
|
+
),
|
|
426
|
+
returned=layout.returned,
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
def _get_hidden_values(
|
|
430
|
+
self, layout: BulkUpdateStatementLayout, values: list[Any], first_row_value: int, row_count: int
|
|
431
|
+
) -> list[Any]:
|
|
432
|
+
"""A statement's parameters with the ``sensitive=True`` fields' values never shown.
|
|
433
|
+
|
|
434
|
+
Args:
|
|
435
|
+
layout: What every statement of this call shares.
|
|
436
|
+
values: The parameters.
|
|
437
|
+
first_row_value: Where the rows' values start among them.
|
|
438
|
+
row_count: The rows.
|
|
439
|
+
|
|
440
|
+
Returns:
|
|
441
|
+
The parameters - a ``QueryParameters`` when a sensitive field is written.
|
|
442
|
+
"""
|
|
443
|
+
if not self.model._meta.sensitive_fields:
|
|
444
|
+
return values
|
|
445
|
+
sensitive_positions = BulkWriteBatches.get_sensitive_positions(self.model, layout.row_fields)
|
|
446
|
+
if not sensitive_positions:
|
|
447
|
+
return values
|
|
448
|
+
row_width = len(layout.row_fields)
|
|
449
|
+
return QueryParameters(
|
|
450
|
+
values,
|
|
451
|
+
[
|
|
452
|
+
first_row_value + row_index * row_width + position
|
|
453
|
+
for row_index in range(row_count)
|
|
454
|
+
for position in sensitive_positions
|
|
455
|
+
],
|
|
456
|
+
)
|
|
457
|
+
|
|
458
|
+
def _make_whole_rows_query(
|
|
459
|
+
self, layout: BulkUpdateStatementLayout, objects_item: list[TModel]
|
|
460
|
+
) -> tuple[str, list[Any], list[TModel]]:
|
|
461
|
+
"""The UPDATE of one batch whose rows the field codecs serialize whole - the key, the old
|
|
462
|
+
version and the fields of every row in one serialization; the VALUES text depends only on
|
|
463
|
+
the placeholders and the row count.
|
|
464
|
+
|
|
465
|
+
Args:
|
|
466
|
+
layout: What every statement of this call shares.
|
|
467
|
+
objects_item: The batch's objects.
|
|
468
|
+
|
|
469
|
+
Returns:
|
|
470
|
+
The statement, its parameters and the objects.
|
|
471
|
+
"""
|
|
472
|
+
parameterizer = Parameterizer()
|
|
473
|
+
values_context = layout.base_context.copy(parameterizer=parameterizer)
|
|
474
|
+
# The WITH clause is rendered first - its parameters come first.
|
|
475
|
+
with_sql = QuerySqlRendering.with_sql(self.query._with, values_context) if self.query._with else ""
|
|
476
|
+
row_fields = layout.row_fields
|
|
477
|
+
values_before_rows = len(parameterizer.values)
|
|
478
|
+
parameters = BulkWriteBatches.write_statement_parameters(
|
|
479
|
+
self.model, self._connection, objects_item, row_fields, list(parameterizer.values)
|
|
480
|
+
)
|
|
481
|
+
rows = (
|
|
482
|
+
BulkWriteBatches.serialize_instances(self.model, self._connection.dialect.types, objects_item, row_fields)
|
|
483
|
+
if parameters is None
|
|
484
|
+
else None
|
|
485
|
+
)
|
|
486
|
+
row_count = len(objects_item) if rows is None else len(rows)
|
|
487
|
+
values_sql = BulkWriteBatches.get_values_rows_sql(
|
|
488
|
+
self.model, layout.row_placeholder_templates, values_before_rows + 1, row_count
|
|
489
|
+
)
|
|
490
|
+
if rows is None:
|
|
491
|
+
# The rows' places in the numbering - their values come from the parameters.
|
|
492
|
+
parameterizer.values.extend(repeat(None, row_count * len(row_fields)))
|
|
493
|
+
else:
|
|
494
|
+
parameterizer.values.extend(chain.from_iterable(rows))
|
|
495
|
+
update_sql = self._get_update_sql(layout, values_context, with_sql, values_sql)
|
|
496
|
+
if parameters is not None:
|
|
497
|
+
values_after_rows = parameterizer.values[values_before_rows + row_count * len(row_fields) :]
|
|
498
|
+
return (
|
|
499
|
+
update_sql,
|
|
500
|
+
parameters.extended(values_after_rows) if values_after_rows else parameters,
|
|
501
|
+
objects_item,
|
|
502
|
+
)
|
|
503
|
+
statement_values = self._get_hidden_values(layout, parameterizer.values, values_before_rows, row_count)
|
|
504
|
+
return update_sql, statement_values, objects_item
|
|
505
|
+
|
|
506
|
+
def _make_query_by_value(
|
|
507
|
+
self, layout: BulkUpdateStatementLayout, objects_item: list[TModel], *, parameters_inline: bool
|
|
508
|
+
) -> tuple[str, list[Any], list[TModel]]:
|
|
509
|
+
"""The UPDATE of one batch built value by value - parameterized, each value is appended to the
|
|
510
|
+
parameters with its placeholder text; inlined, it is rendered as a literal.
|
|
511
|
+
|
|
512
|
+
Args:
|
|
513
|
+
layout: What every statement of this call shares.
|
|
514
|
+
objects_item: The batch's objects.
|
|
515
|
+
parameters_inline: Whether every value is written into the SQL text.
|
|
516
|
+
|
|
517
|
+
Returns:
|
|
518
|
+
The statement, its parameters and the objects.
|
|
519
|
+
"""
|
|
520
|
+
parameterizer = None if parameters_inline else Parameterizer()
|
|
521
|
+
values_context = (
|
|
522
|
+
layout.base_context if parameterizer is None else layout.base_context.copy(parameterizer=parameterizer)
|
|
523
|
+
)
|
|
524
|
+
# The WITH clause is rendered first - its parameters come first.
|
|
525
|
+
with_sql = QuerySqlRendering.with_sql(self.query._with, values_context) if self.query._with else ""
|
|
526
|
+
field_rows = BulkWriteBatches.serialize_instances(
|
|
527
|
+
self.model, self._connection.dialect.types, objects_item, layout.fields
|
|
528
|
+
)
|
|
529
|
+
rows_sql = []
|
|
530
|
+
parameter_offset = 0 if parameterizer is None else len(parameterizer.values)
|
|
531
|
+
# Each row's key, old version and fields follow the values bound before the rows.
|
|
532
|
+
first_row_value = parameter_offset
|
|
533
|
+
types = self.dialect.types
|
|
534
|
+
for obj, field_values in zip(objects_item, field_rows, strict=True):
|
|
535
|
+
pk_values = obj.pk if layout.pk_column_count > 1 else (obj.pk,)
|
|
536
|
+
key_values = self._pk_and_version_db_values(
|
|
537
|
+
types,
|
|
538
|
+
obj,
|
|
539
|
+
pk_values,
|
|
540
|
+
layout.pk_field_objects,
|
|
541
|
+
layout.optimistic_lock_field_object,
|
|
542
|
+
layout.optimistic_lock_field,
|
|
543
|
+
)
|
|
544
|
+
row_parts = []
|
|
545
|
+
if parameterizer is not None:
|
|
546
|
+
for value, template in chain(
|
|
547
|
+
zip(key_values, layout.key_placeholder_templates, strict=True),
|
|
548
|
+
zip(field_values, layout.field_placeholder_templates, strict=True),
|
|
549
|
+
):
|
|
550
|
+
parameter_offset += 1
|
|
551
|
+
parameterizer.values.append(value)
|
|
552
|
+
row_parts.append(template.format(parameter_offset))
|
|
553
|
+
else:
|
|
554
|
+
for value, cast_type in chain(
|
|
555
|
+
zip(key_values, layout.key_cast_types, strict=True),
|
|
556
|
+
zip(field_values, layout.field_cast_types, strict=True),
|
|
557
|
+
):
|
|
558
|
+
wrapped = self.query._wrapper_class(value)
|
|
559
|
+
term = Cast(wrapped, cast_type) if cast_type is not None else wrapped
|
|
560
|
+
row_parts.append(term.get_sql(values_context))
|
|
561
|
+
rows_sql.append("(" + ", ".join(row_parts) + ")")
|
|
562
|
+
update_sql = self._get_update_sql(layout, values_context, with_sql, ", ".join(rows_sql))
|
|
563
|
+
if parameterizer is None:
|
|
564
|
+
return update_sql, [], objects_item
|
|
565
|
+
statement_values = self._get_hidden_values(layout, parameterizer.values, first_row_value, len(objects_item))
|
|
566
|
+
return update_sql, statement_values, objects_item
|
|
567
|
+
|
|
568
|
+
def _get_fixed_parameter_count(self, base_context: Any, extra_where: Term | None) -> int:
|
|
569
|
+
"""Bind parameters every statement of this call carries besides its VALUES rows.
|
|
570
|
+
|
|
571
|
+
Args:
|
|
572
|
+
base_context: The dialect's base SQL context.
|
|
573
|
+
extra_where: The queryset's own filter, or None.
|
|
574
|
+
|
|
575
|
+
Returns:
|
|
576
|
+
The parameter count of the CTE bodies and the filter.
|
|
577
|
+
"""
|
|
578
|
+
parameterizer = Parameterizer()
|
|
579
|
+
fixed_context = base_context.copy(parameterizer=parameterizer)
|
|
580
|
+
if self.query._with:
|
|
581
|
+
QuerySqlRendering.with_sql(self.query._with, fixed_context)
|
|
582
|
+
if extra_where:
|
|
583
|
+
extra_where.get_sql(fixed_context.copy(subquery=True, with_namespace=True))
|
|
584
|
+
return len(parameterizer.values)
|
|
585
|
+
|
|
586
|
+
def _read_returned_keys(
|
|
587
|
+
self, rows: Sequence[Any], pk_fields: list[Field[Any]], columns: list[str], *, rows_by_name: bool
|
|
588
|
+
) -> list[Any]:
|
|
589
|
+
"""The primary key of each ``RETURNING`` row, as the objects hold it.
|
|
590
|
+
|
|
591
|
+
Args:
|
|
592
|
+
rows: The rows, the key's columns first.
|
|
593
|
+
pk_fields: The primary key's fields.
|
|
594
|
+
columns: The primary key's columns.
|
|
595
|
+
rows_by_name: Whether the rows are mappings of column names - read without the accelerator.
|
|
596
|
+
|
|
597
|
+
Returns:
|
|
598
|
+
One key per row - a tuple for a composite key.
|
|
599
|
+
"""
|
|
600
|
+
types = self.dialect.types
|
|
601
|
+
is_composite = len(pk_fields) > 1
|
|
602
|
+
|
|
603
|
+
def read_in_python() -> list[Any]:
|
|
604
|
+
# A driver's row may have no .get() - read as a dict.
|
|
605
|
+
keys = [
|
|
606
|
+
tuple(
|
|
607
|
+
types.get_python_value(field, row.get(column))
|
|
608
|
+
for field, column in zip(pk_fields, columns, strict=True)
|
|
609
|
+
)
|
|
610
|
+
for row in map(dict, rows)
|
|
611
|
+
]
|
|
612
|
+
return keys if is_composite else [key for (key,) in keys]
|
|
613
|
+
|
|
614
|
+
if HydrateAccelerator.module is None or not rows or rows_by_name:
|
|
615
|
+
return read_in_python()
|
|
616
|
+
reader = HydrateAccelerator.get_values_reader(
|
|
617
|
+
self.model,
|
|
618
|
+
tuple(ValueField(self.model, field.model_field_name, field, False) for field in pk_fields),
|
|
619
|
+
self._connection,
|
|
620
|
+
)
|
|
621
|
+
read = reader.read_tuples if is_composite else reader.read_flat
|
|
622
|
+
return cast("list[Any]", HydrateAccelerator.run_or_fall_back(lambda: read(list(rows)), read_in_python))
|
|
623
|
+
|
|
624
|
+
async def _count_stale_objects(self, not_updated_objects: list[TModel]) -> int:
|
|
625
|
+
"""Counts the objects whose row the UPDATE skipped for a stale ``Meta.optimistic_lock_field``,
|
|
626
|
+
rather than for the queryset's own filter.
|
|
627
|
+
|
|
628
|
+
Args:
|
|
629
|
+
not_updated_objects: Objects of one batch whose row the UPDATE didn't touch.
|
|
630
|
+
|
|
631
|
+
Returns:
|
|
632
|
+
How many of them are stale - a row that no longer exists counts too.
|
|
633
|
+
"""
|
|
634
|
+
if not not_updated_objects or self._filter_criterion is None:
|
|
635
|
+
return len(not_updated_objects)
|
|
636
|
+
primary_key_attribute_names = self.model._meta.primary_key_attribute_names
|
|
637
|
+
pk_field_objs = [self.model._meta.fields_map[name] for name in primary_key_attribute_names]
|
|
638
|
+
pk_columns = [
|
|
639
|
+
field_obj.source_field or name
|
|
640
|
+
for field_obj, name in zip(pk_field_objs, primary_key_attribute_names, strict=True)
|
|
641
|
+
]
|
|
642
|
+
table = self.model._meta.basetable
|
|
643
|
+
pk_terms = [table[column] for column in pk_columns]
|
|
644
|
+
pk_values = [obj.pk if len(primary_key_attribute_names) > 1 else (obj.pk,) for obj in not_updated_objects]
|
|
645
|
+
db_pk_values = [
|
|
646
|
+
[
|
|
647
|
+
self.dialect.types.get_db_value(field_obj, value, None)
|
|
648
|
+
for field_obj, value in zip(pk_field_objs, pk_value, strict=True)
|
|
649
|
+
]
|
|
650
|
+
for pk_value in pk_values
|
|
651
|
+
]
|
|
652
|
+
if len(pk_terms) == 1:
|
|
653
|
+
pk_condition = pk_terms[0].isin([db_pk_value[0] for db_pk_value in db_pk_values])
|
|
654
|
+
else:
|
|
655
|
+
pk_condition = Tuple(*pk_terms).isin(RowValueList(*[Tuple(*db_pk_value) for db_pk_value in db_pk_values]))
|
|
656
|
+
matches_filter = (
|
|
657
|
+
Case(alias=BULK_UPDATE_MATCHES_FILTER_ALIAS)
|
|
658
|
+
.when(self._filter_criterion, LiteralValue("1"))
|
|
659
|
+
.else_(LiteralValue("0"))
|
|
660
|
+
)
|
|
661
|
+
query = self._connection.query_class.from_(table).select(*pk_terms, matches_filter).where(pk_condition)
|
|
662
|
+
query._with = list(self.query._with)
|
|
663
|
+
_, rows = await self._connection.execute(*query.get_parameterized_sql())
|
|
664
|
+
excluded_by_filter_count = sum(1 for row in rows if not int(dict(row)[BULK_UPDATE_MATCHES_FILTER_ALIAS]))
|
|
665
|
+
return len(not_updated_objects) - excluded_by_filter_count
|
|
666
|
+
|
|
667
|
+
async def _execute_many(
|
|
668
|
+
self,
|
|
669
|
+
queries_with_parameters: list[tuple[str, Any, list[TModel]]],
|
|
670
|
+
stamped_values: InstanceValues | None = None,
|
|
671
|
+
) -> int | None:
|
|
672
|
+
"""Runs every statement, then raises for the stale objects found across all of them.
|
|
673
|
+
|
|
674
|
+
Args:
|
|
675
|
+
queries_with_parameters: One ``(sql, values, objects)`` entry per statement.
|
|
676
|
+
stamped_values: The auto_now values serialization stamped on the objects.
|
|
677
|
+
|
|
678
|
+
Returns:
|
|
679
|
+
The number of updated rows.
|
|
680
|
+
|
|
681
|
+
Raises:
|
|
682
|
+
StaleObjectError: An object had a stale ``Meta.optimistic_lock_field``.
|
|
683
|
+
"""
|
|
684
|
+
count, stale_object_count = await self._execute_statements(queries_with_parameters, stamped_values)
|
|
685
|
+
self._raise_for_stale_objects(stale_object_count)
|
|
686
|
+
return count
|
|
687
|
+
|
|
688
|
+
def _raise_for_stale_objects(self, stale_object_count: int) -> None:
|
|
689
|
+
"""Raises when any object of this call had a stale ``Meta.optimistic_lock_field``.
|
|
690
|
+
|
|
691
|
+
Args:
|
|
692
|
+
stale_object_count: How many objects across every statement were stale.
|
|
693
|
+
|
|
694
|
+
Raises:
|
|
695
|
+
StaleObjectError: ``stale_object_count`` is not zero.
|
|
696
|
+
"""
|
|
697
|
+
if stale_object_count:
|
|
698
|
+
# No single pk/expected_version to attach here - unlike save()/delete()/restore()
|
|
699
|
+
# (always exactly one instance), a batch UPDATE's affected-rowcount alone can't tell
|
|
700
|
+
# WHICH object(s) across the whole call were stale, only how many.
|
|
701
|
+
raise StaleObjectError(
|
|
702
|
+
f"bulk_update() on {self.model.__name__}: {stale_object_count} object(s) "
|
|
703
|
+
"across this call had a stale version",
|
|
704
|
+
self.model,
|
|
705
|
+
None,
|
|
706
|
+
None,
|
|
707
|
+
)
|
|
708
|
+
|
|
709
|
+
async def _execute_statements(
|
|
710
|
+
self,
|
|
711
|
+
queries_with_parameters: list[tuple[str, Any, list[TModel]]],
|
|
712
|
+
stamped_values: InstanceValues | None = None,
|
|
713
|
+
) -> tuple[int | None, int]:
|
|
714
|
+
"""Runs every statement of this call, syncing each updated object's in-memory state - every
|
|
715
|
+
object counts as written where the database returns no row.
|
|
716
|
+
|
|
717
|
+
Args:
|
|
718
|
+
queries_with_parameters: One ``(sql, values, objects)`` entry per statement.
|
|
719
|
+
stamped_values: The auto_now values serialization stamped on the objects.
|
|
720
|
+
|
|
721
|
+
Returns:
|
|
722
|
+
The number of updated rows - None where the database reports none - and the number of
|
|
723
|
+
stale objects across every statement.
|
|
724
|
+
"""
|
|
725
|
+
optimistic_lock_field = self.model._meta.optimistic_lock_field
|
|
726
|
+
track_dirty = self.model._meta.track_dirty_fields
|
|
727
|
+
primary_key_attribute_names = self.model._meta.primary_key_attribute_names
|
|
728
|
+
pk_field_objs = [self.model._meta.fields_map[name] for name in primary_key_attribute_names]
|
|
729
|
+
source_primary_key_attributes = [
|
|
730
|
+
obj.source_field or name for obj, name in zip(pk_field_objs, primary_key_attribute_names, strict=True)
|
|
731
|
+
]
|
|
732
|
+
populate_generated_fields = bool(self._returning and self.model._meta.generated_db_fields)
|
|
733
|
+
supports_returning = self.dialect.features.supports_returning
|
|
734
|
+
# Told to the connection - a statement of many rows is long to search for its RETURNING.
|
|
735
|
+
returns_rows = (populate_generated_fields or self._reads_written_keys()) and supports_returning
|
|
736
|
+
stamped_values = stamped_values or InstanceValues()
|
|
737
|
+
# An object's primary key as _read_returned_keys() gives a row's: a tuple for a composite key.
|
|
738
|
+
get_key = attrgetter(*primary_key_attribute_names)
|
|
739
|
+
count: int | None = 0
|
|
740
|
+
# Counted over every chunk - raised once all were attempted.
|
|
741
|
+
total_stale_object_count = 0
|
|
742
|
+
# The driver's own parameters (write_parameters()) hide no sensitive value - the run does.
|
|
743
|
+
hides_written_values = bool(self.model._meta.sensitive_fields)
|
|
744
|
+
for sql, values, objects_item in queries_with_parameters:
|
|
745
|
+
statement = self._connection.execute(sql, values, returns_rows=returns_rows)
|
|
746
|
+
if hides_written_values and not isinstance(values, list):
|
|
747
|
+
rows_affected, returned_rows = await BulkWriteBatches.run_hiding_sensitive_values(
|
|
748
|
+
statement, self.model, objects_item, list(self.fields)
|
|
749
|
+
)
|
|
750
|
+
else:
|
|
751
|
+
rows_affected, returned_rows = await statement
|
|
752
|
+
self._completed_objects.extend(objects_item)
|
|
753
|
+
stale_object_count = 0
|
|
754
|
+
if optimistic_lock_field or track_dirty or stamped_values.old_values:
|
|
755
|
+
# RETURNING names the rows the UPDATE wrote. Only those objects get their version
|
|
756
|
+
# and dirty baseline updated; any other gets its stamped auto_now values put back.
|
|
757
|
+
# Without RETURNING every object counts as written.
|
|
758
|
+
updated_pk_values = (
|
|
759
|
+
set(
|
|
760
|
+
self._read_returned_keys(
|
|
761
|
+
returned_rows, pk_field_objs, source_primary_key_attributes, rows_by_name=False
|
|
762
|
+
)
|
|
763
|
+
)
|
|
764
|
+
if supports_returning
|
|
765
|
+
else None
|
|
766
|
+
)
|
|
767
|
+
# Only the written fields become clean - other unsaved changes of the object stay
|
|
768
|
+
# dirty.
|
|
769
|
+
fields_to_sync = self._rules.get_updated_names()
|
|
770
|
+
is_written = (
|
|
771
|
+
[True] * len(objects_item)
|
|
772
|
+
if updated_pk_values is None
|
|
773
|
+
else list(map(updated_pk_values.__contains__, map(get_key, objects_item)))
|
|
774
|
+
)
|
|
775
|
+
written_objects = list(compress(objects_item, is_written))
|
|
776
|
+
unwritten_objects = list(compress(objects_item, map(not_, is_written)))
|
|
777
|
+
self._unwritten_objects.extend(unwritten_objects)
|
|
778
|
+
if optimistic_lock_field or track_dirty:
|
|
779
|
+
for obj in written_objects:
|
|
780
|
+
# The version bump is registered to be put back if the transaction rolls back.
|
|
781
|
+
if optimistic_lock_field:
|
|
782
|
+
stamped_values.bump_optimistic_lock(obj, optimistic_lock_field)
|
|
783
|
+
if track_dirty:
|
|
784
|
+
DirtyFields.sync_dirty_snapshot_fields(obj, fields_to_sync, self._connection)
|
|
785
|
+
if stamped_values.old_values:
|
|
786
|
+
stamped_values.keep(self._connection, written_objects)
|
|
787
|
+
if unwritten_objects:
|
|
788
|
+
stamped_values.restore(unwritten_objects)
|
|
789
|
+
if optimistic_lock_field and rows_affected is not None and rows_affected < len(objects_item):
|
|
790
|
+
stale_object_count = await self._count_stale_objects(unwritten_objects)
|
|
791
|
+
if populate_generated_fields and not supports_returning:
|
|
792
|
+
ReturnedValues.leave_unloaded(self.model, objects_item, self.model._meta.generated_db_fields)
|
|
793
|
+
elif populate_generated_fields:
|
|
794
|
+
# UPDATE ... FROM (VALUES ...) returns its rows in no particular order - matched by
|
|
795
|
+
# primary key; the key itself isn't set again.
|
|
796
|
+
for obj, row in ReturnedValues.match_rows(
|
|
797
|
+
self.model, self.dialect.types, objects_item, returned_rows, primary_key_attribute_names
|
|
798
|
+
):
|
|
799
|
+
ReturnedValues.apply_row(
|
|
800
|
+
self.model,
|
|
801
|
+
self.dialect.types,
|
|
802
|
+
obj,
|
|
803
|
+
row,
|
|
804
|
+
[column for column in row if column not in source_primary_key_attributes],
|
|
805
|
+
)
|
|
806
|
+
if stale_object_count:
|
|
807
|
+
# Every chunk is its own UPDATE - a stale object in one doesn't stop the others;
|
|
808
|
+
# raised after the loop.
|
|
809
|
+
total_stale_object_count += stale_object_count
|
|
810
|
+
count = None if count is None or rows_affected is None else count + rows_affected
|
|
811
|
+
return count, total_stale_object_count
|
|
812
|
+
|
|
813
|
+
def __await__(self) -> Generator[Any, Any, int | None]:
|
|
814
|
+
if self._is_none:
|
|
815
|
+
return self._execute_none().__await__()
|
|
816
|
+
query = self._get_execution_query(True)
|
|
817
|
+
capture_needs = query.model._meta.change_capture_needs
|
|
818
|
+
if capture_needs is not None and capture_needs.captures(RowOperation.UPDATE):
|
|
819
|
+
return WriteSteps.run_whole(query._connection, query._run_captured_bulk_update(capture_needs)).__await__()
|
|
820
|
+
return WriteSteps.get_whole_run(query._connection, query._report_bulk_update(query._run())).__await__()
|
|
821
|
+
|
|
822
|
+
async def _run_captured_bulk_update(self, capture_needs: CaptureNeeds) -> int | None:
|
|
823
|
+
"""Runs the update of a model with ``Meta.change_capture`` and captures its rows - in one
|
|
824
|
+
transaction with their events, so an error leaves no row of the call written. The rows as they
|
|
825
|
+
were come from the objects' dirty-field snapshots, else from reading them first, locked; as they
|
|
826
|
+
are after, from reading them after. A stale object isn't such an error: the other rows are
|
|
827
|
+
written and captured, and ``StaleObjectError`` is raised once the transaction commits.
|
|
828
|
+
|
|
829
|
+
Args:
|
|
830
|
+
capture_needs: The model's needs.
|
|
831
|
+
|
|
832
|
+
Returns:
|
|
833
|
+
How many rows it updated.
|
|
834
|
+
"""
|
|
835
|
+
captured = CapturedWrite(
|
|
836
|
+
self.model,
|
|
837
|
+
capture_needs,
|
|
838
|
+
self._connection,
|
|
839
|
+
RowOperation.UPDATE,
|
|
840
|
+
changed=self._rules.changed_field_names,
|
|
841
|
+
)
|
|
842
|
+
async with captured.transaction() as connection:
|
|
843
|
+
if connection is not self._connection:
|
|
844
|
+
self._apply_connection(connection)
|
|
845
|
+
self._connection_explicitly_chosen = True
|
|
846
|
+
objects = list(self._objects)
|
|
847
|
+
self._objects = objects
|
|
848
|
+
pks = [obj.pk for obj in objects]
|
|
849
|
+
before_by_pk: dict[Any, Any] = {}
|
|
850
|
+
if capture_needs.reads_before:
|
|
851
|
+
unread_pks = []
|
|
852
|
+
for obj in objects:
|
|
853
|
+
snapshot_values = InstanceCapture.get_snapshot_values(obj, capture_needs)
|
|
854
|
+
if snapshot_values is None:
|
|
855
|
+
unread_pks.append(obj.pk)
|
|
856
|
+
else:
|
|
857
|
+
before_by_pk[obj.pk] = snapshot_values
|
|
858
|
+
if unread_pks:
|
|
859
|
+
before_by_pk.update(await captured.read_before(unread_pks))
|
|
860
|
+
stale_error: StaleObjectError | None = None
|
|
861
|
+
try:
|
|
862
|
+
count = await self._report_bulk_update(self._run())
|
|
863
|
+
except StaleObjectError as error:
|
|
864
|
+
stale_error = error
|
|
865
|
+
except BaseException:
|
|
866
|
+
if not connection.features.supports_transactions and self._completed_objects:
|
|
867
|
+
# No transaction undoes the batches written before the error - their rows are captured.
|
|
868
|
+
completed_pks = [obj.pk for obj in self._completed_objects if obj not in self._unwritten_objects]
|
|
869
|
+
await self._capture_rows(captured, completed_pks, before_by_pk)
|
|
870
|
+
raise
|
|
871
|
+
if self._unwritten_objects:
|
|
872
|
+
unwritten_pks = {obj.pk for obj in self._unwritten_objects}
|
|
873
|
+
pks = [pk for pk in pks if pk not in unwritten_pks]
|
|
874
|
+
await self._capture_rows(captured, pks, before_by_pk)
|
|
875
|
+
if stale_error is not None:
|
|
876
|
+
raise stale_error
|
|
877
|
+
return count
|
|
878
|
+
|
|
879
|
+
@staticmethod
|
|
880
|
+
async def _capture_rows(captured: CapturedWrite, pks: list[Any], before_by_pk: dict[Any, Any]) -> None:
|
|
881
|
+
"""Captures the rows the update wrote - their values read after it.
|
|
882
|
+
|
|
883
|
+
Args:
|
|
884
|
+
captured: The capture of the update.
|
|
885
|
+
pks: The keys of the rows written.
|
|
886
|
+
before_by_pk: The rows' captured values before the update, by primary key.
|
|
887
|
+
"""
|
|
888
|
+
after_by_pk = await captured.read(pks)
|
|
889
|
+
await captured.capture_values(
|
|
890
|
+
(pk, before_by_pk.get(pk), values, tenant) for pk, (values, tenant) in after_by_pk.items()
|
|
891
|
+
)
|
|
892
|
+
|
|
893
|
+
async def _report_bulk_update(self, update: Awaitable[int | None]) -> int | None:
|
|
894
|
+
"""Runs the update and reports its objects' rows (``ChangeEvents``) - also when it fails with
|
|
895
|
+
rows left written: a stale object fails the call after the other rows are written, and
|
|
896
|
+
batches of an explicit ``batch_size`` are statements of their own.
|
|
897
|
+
|
|
898
|
+
Args:
|
|
899
|
+
update: The update.
|
|
900
|
+
|
|
901
|
+
Returns:
|
|
902
|
+
How many rows it updated.
|
|
903
|
+
"""
|
|
904
|
+
try:
|
|
905
|
+
count = await update
|
|
906
|
+
except StaleObjectError:
|
|
907
|
+
await self._report_updated_objects()
|
|
908
|
+
raise
|
|
909
|
+
except BaseException:
|
|
910
|
+
if self._batch_size is not None:
|
|
911
|
+
await self._report_updated_objects(completed_only=True)
|
|
912
|
+
raise
|
|
913
|
+
await self._report_updated_objects()
|
|
914
|
+
return count
|
|
915
|
+
|
|
916
|
+
async def _report_updated_objects(self, *, completed_only: bool = False) -> None:
|
|
917
|
+
"""Reports the rows ``bulk_update()`` wrote of the objects it was given (``ChangeEvents``).
|
|
918
|
+
|
|
919
|
+
Args:
|
|
920
|
+
completed_only: Whether only the objects of the statements that ran to the end are
|
|
921
|
+
reported - of a call that failed.
|
|
922
|
+
"""
|
|
923
|
+
if not ChangeEvents.is_observed(self.model):
|
|
924
|
+
return
|
|
925
|
+
instances = list(self._completed_objects if completed_only else self._objects)
|
|
926
|
+
if not instances:
|
|
927
|
+
return
|
|
928
|
+
if self._unwritten_objects:
|
|
929
|
+
unwritten_object_ids = set(map(id, self._unwritten_objects))
|
|
930
|
+
instances = [obj for obj in instances if id(obj) not in unwritten_object_ids]
|
|
931
|
+
await WriteSteps.report(
|
|
932
|
+
self._connection,
|
|
933
|
+
self.model,
|
|
934
|
+
RowOperation.UPDATE,
|
|
935
|
+
instances=instances,
|
|
936
|
+
fields=self._rules.changed_field_names,
|
|
937
|
+
)
|
|
938
|
+
|
|
939
|
+
def _scope_to_active_tenant(self) -> None:
|
|
940
|
+
"""Checks every object belongs to the model's tenant scope and, for a query outside its
|
|
941
|
+
model's default scope, adds the tenant condition the default scope would - a write reaches
|
|
942
|
+
only the scope's rows whatever an object claims.
|
|
943
|
+
|
|
944
|
+
Raises:
|
|
945
|
+
QueryError: The model has no tenant scope, or an object belongs to a tenant outside it.
|
|
946
|
+
"""
|
|
947
|
+
if not self._tenant_scoped:
|
|
948
|
+
return
|
|
949
|
+
scope = TenantWriteRules.scope_objects(
|
|
950
|
+
self.model, self._objects, "bulk_update", fills_missing=False, requires_active=True
|
|
951
|
+
)
|
|
952
|
+
if not self._uses_default_scope:
|
|
953
|
+
scope_filter = TenantScope.get_scope_filter(cast("str", self.model._meta.tenant_field), scope)
|
|
954
|
+
if scope_filter is not None:
|
|
955
|
+
self._q_objects = [*self._q_objects, Q(**{scope_filter[0]: scope_filter[1]})]
|
|
956
|
+
|
|
957
|
+
async def _run(self) -> int | None:
|
|
958
|
+
# A pending async default is resolved before the values are read, as save() does.
|
|
959
|
+
self._objects = list(self._objects)
|
|
960
|
+
self._unwritten_objects = []
|
|
961
|
+
self._completed_objects = []
|
|
962
|
+
WrittenTargetChecks.raise_if_refused_calls(self)
|
|
963
|
+
self._scope_to_active_tenant()
|
|
964
|
+
for obj in self._objects:
|
|
965
|
+
if obj._await_when_save:
|
|
966
|
+
await InstanceSaving.set_async_default_field(obj)
|
|
967
|
+
await Tenancy.check_objects_relation_targets(self.model, self._objects, self._connection, self.fields)
|
|
968
|
+
return await self._write_checked_objects()
|
|
969
|
+
|
|
970
|
+
async def _write_checked_objects(self) -> int | None:
|
|
971
|
+
"""Writes the objects once their relations are checked.
|
|
972
|
+
|
|
973
|
+
Returns:
|
|
974
|
+
How many rows it updated.
|
|
975
|
+
"""
|
|
976
|
+
# The stamps and blind indexes the update gives the objects - an object whose row isn't written
|
|
977
|
+
# gets them put back.
|
|
978
|
+
stamped_values = InstanceValues()
|
|
979
|
+
self._rules.stamp(self._objects, stamped_values)
|
|
980
|
+
try:
|
|
981
|
+
queries = self._make_queries()
|
|
982
|
+
if len(queries) == 1 or self._batch_size is not None:
|
|
983
|
+
# One statement is atomic on its own; batches the caller asked for explicitly run as
|
|
984
|
+
# independent statements, as documented.
|
|
985
|
+
return await self._execute_many(queries, stamped_values)
|
|
986
|
+
# Batches split off only to stay under the bind-parameter ceiling run in one transaction,
|
|
987
|
+
# so a failure in any of them leaves no row updated - a stale version is not a failure
|
|
988
|
+
# and doesn't roll back the other rows, exactly as with a single statement.
|
|
989
|
+
original_connection = self._connection
|
|
990
|
+
try:
|
|
991
|
+
async with original_connection._in_transaction() as transaction_connection:
|
|
992
|
+
self._connection = transaction_connection
|
|
993
|
+
try:
|
|
994
|
+
count, stale_object_count = await self._execute_statements(queries, stamped_values)
|
|
995
|
+
finally:
|
|
996
|
+
self._connection = original_connection
|
|
997
|
+
except BaseException:
|
|
998
|
+
stamped_values.restore()
|
|
999
|
+
raise
|
|
1000
|
+
self._raise_for_stale_objects(stale_object_count)
|
|
1001
|
+
return count
|
|
1002
|
+
except (ValidationError, TypeError) as error:
|
|
1003
|
+
stamped_values.restore()
|
|
1004
|
+
# A value that failed to bind - an expression, or a field never given a value - is named.
|
|
1005
|
+
self._rules.raise_if_unbound_values(self._objects, self._rules.field_names, error)
|
|
1006
|
+
raise
|
|
1007
|
+
|
|
1008
|
+
def _get_statements(self, parameters_inline: bool) -> list[tuple[str, list[Any]]]:
|
|
1009
|
+
# Copies holding the stamps - showing the statements changes no object.
|
|
1010
|
+
self._objects = self._rules.get_stamped_copies(list(self._objects))
|
|
1011
|
+
self._scope_to_active_tenant()
|
|
1012
|
+
return [(sql, values) for sql, values, _objects in self._make_queries(parameters_inline=parameters_inline)]
|