simple-module-db 0.0.49__tar.gz → 0.0.50__tar.gz
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.
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/PKG-INFO +4 -4
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/README.md +1 -1
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/pyproject.toml +3 -3
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/simple_module_db/__init__.py +33 -24
- simple_module_db-0.0.50/simple_module_db/_core_walk.py +13 -0
- simple_module_db-0.0.50/simple_module_db/admission.py +13 -0
- simple_module_db-0.0.50/simple_module_db/audit.py +13 -0
- simple_module_db-0.0.50/simple_module_db/audit_sinks.py +13 -0
- simple_module_db-0.0.50/simple_module_db/auditing/__init__.py +1 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/auditing}/_bulk_audit_records.py +14 -6
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/auditing}/_bulk_pk_update.py +1 -1
- simple_module_db-0.0.50/simple_module_db/auditing/_pk.py +26 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/auditing}/audit.py +33 -24
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/auditing}/audit_redaction.py +1 -1
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/auditing}/audit_sinks.py +1 -1
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/auditing}/bulk_audit.py +11 -10
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/auditing}/bulk_audit_targets.py +1 -1
- simple_module_db-0.0.50/simple_module_db/base.py +13 -0
- simple_module_db-0.0.50/simple_module_db/callbacks.py +13 -0
- simple_module_db-0.0.50/simple_module_db/core_scope.py +13 -0
- simple_module_db-0.0.50/simple_module_db/data_compatibility.py +13 -0
- simple_module_db-0.0.50/simple_module_db/deps.py +13 -0
- simple_module_db-0.0.50/simple_module_db/engine/__init__.py +1 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/deps.py +3 -3
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/independent.py +2 -2
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/leases.py +54 -7
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/query_stats.py +1 -1
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/session.py +5 -5
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/transaction.py +2 -2
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/writes.py +2 -2
- simple_module_db-0.0.50/simple_module_db/engine_options.py +13 -0
- simple_module_db-0.0.50/simple_module_db/extensions.py +13 -0
- simple_module_db-0.0.50/simple_module_db/independent.py +13 -0
- simple_module_db-0.0.50/simple_module_db/leases.py +13 -0
- simple_module_db-0.0.50/simple_module_db/listeners.py +13 -0
- simple_module_db-0.0.50/simple_module_db/migration_state.py +13 -0
- simple_module_db-0.0.50/simple_module_db/mixins.py +13 -0
- simple_module_db-0.0.50/simple_module_db/models/__init__.py +1 -0
- simple_module_db-0.0.50/simple_module_db/models/credential.py +15 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/models}/extensions.py +3 -3
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/models}/listeners.py +27 -15
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/models}/mixins.py +3 -3
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/models}/model_registry.py +3 -3
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/models}/types.py +1 -1
- simple_module_db-0.0.50/simple_module_db/pagination.py +13 -0
- simple_module_db-0.0.50/simple_module_db/principals.py +13 -0
- simple_module_db-0.0.50/simple_module_db/provider.py +13 -0
- simple_module_db-0.0.50/simple_module_db/queries/__init__.py +1 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/queries}/pagination.py +1 -1
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/queries}/principals.py +16 -7
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/queries}/resource_policy.py +3 -3
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/queries}/stored_settings.py +4 -4
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/queries}/user_directory_sql.py +10 -8
- simple_module_db-0.0.50/simple_module_db/query_filter.py +13 -0
- simple_module_db-0.0.50/simple_module_db/query_stats.py +13 -0
- simple_module_db-0.0.50/simple_module_db/resource_policy.py +13 -0
- simple_module_db-0.0.50/simple_module_db/schema/__init__.py +1 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/schema}/_migration_render.py +3 -3
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/schema}/data_compatibility.py +5 -5
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/schema}/migration_portability.py +1 -1
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/schema}/migrations.py +9 -9
- simple_module_db-0.0.50/simple_module_db/scope_predicates.py +13 -0
- simple_module_db-0.0.50/simple_module_db/scopes.py +13 -0
- simple_module_db-0.0.50/simple_module_db/scoping/__init__.py +1 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/_builtin_scopes.py +4 -4
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/_core_walk.py +2 -2
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/_engine_policies.py +1 -1
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/_entity_selectables.py +3 -3
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/_persisted_owner.py +2 -2
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/_scope_writes.py +9 -4
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/_secondary_scope.py +3 -3
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/bulk_guard.py +5 -5
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/core_scope.py +8 -4
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/flush_guard.py +4 -4
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/insert_guard.py +2 -2
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/insert_scope.py +1 -1
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/query_filter.py +19 -17
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/scope_predicates.py +5 -5
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/scopes.py +2 -2
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/tenancy.py +1 -1
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/tenant_cleanup.py +8 -4
- simple_module_db-0.0.50/simple_module_db/search.py +13 -0
- simple_module_db-0.0.50/simple_module_db/session.py +13 -0
- simple_module_db-0.0.50/simple_module_db/stored_settings.py +13 -0
- simple_module_db-0.0.50/simple_module_db/tenancy.py +13 -0
- simple_module_db-0.0.50/simple_module_db/tenant_cleanup.py +13 -0
- simple_module_db-0.0.50/simple_module_db/transaction.py +13 -0
- simple_module_db-0.0.50/simple_module_db/types.py +13 -0
- simple_module_db-0.0.50/simple_module_db/user_directory_sql.py +13 -0
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_audit_models.py +2 -2
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_bulk_audit_support.py +4 -4
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_core_scope_models.py +4 -4
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_db_dml_scope_models.py +3 -3
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_db_read_scope_models.py +3 -3
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_db_shape_matrix.py +3 -3
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_models.py +5 -5
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_workspace_scope_models.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/auditing}/test_audit.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/auditing}/test_audit_per_engine.py +6 -6
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/auditing}/test_db_audit_regressions.py +65 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/auditing}/test_db_bulk_audit.py +55 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/auditing}/test_db_credential_audit.py +56 -7
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_engine_options.py +3 -3
- simple_module_db-0.0.50/tests/engine/test_db_layout_shims.py +61 -0
- simple_module_db-0.0.50/tests/engine/test_db_lease_lock_wait.py +288 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_logging.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_query_stats.py +2 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_response_finalization.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_sqlite_admission_lock.py +2 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_sqlite_savepoint.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_sqlite_wal_switch.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_write_marks.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_rollback_logging.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_session.py +2 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_transaction.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_writes.py +6 -6
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/models}/test_aware_datetime.py +17 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/models}/test_base.py +10 -5
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/models}/test_db_credential_log_masking.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/models}/test_db_extensions.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/models}/test_db_extensions_pg.py +6 -6
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/models}/test_db_listeners_attach.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/models}/test_mixins.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/queries}/test_db_pagination_options.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/queries}/test_db_stored_settings.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/queries}/test_db_user_directory_sql.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/queries}/test_principals.py +12 -5
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_db_data_compatibility_doctor.py +8 -8
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_db_doctor_session_filters.py +8 -8
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_db_expression_index_library_warnings.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_db_expression_index_warning_scope.py +2 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_db_migration_doctor.py +2 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_db_migration_review_regressions.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_db_migration_state.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_migration_portability.py +2 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_migrations.py +11 -11
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/schema}/test_migrations_sqlite_index_compare.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_aliased_join_text_scope.py +2 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_aliased_selectable_scope.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_connection_policy.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_core_full_setup_join.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_core_in_orm_select.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_core_join_scope.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_core_nested_scope.py +2 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_dml_target_scope.py +6 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_engine_policy_resolution.py +9 -9
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_flush_persisted_owner.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_insert_select_tenant.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_insert_value_subqueries.py +6 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_nested_dml_and_bulk_api.py +6 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_relationship_loader_scope.py +6 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_secondary_scope_execution.py +2 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_shape_matrix_dml.py +2 -2
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_shape_matrix_joins.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_shape_matrix_selects.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_strict_insert_context.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_tenant_cleanup.py +5 -5
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_db_tenant_upsert_guard.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_multi_tenancy.py +1 -1
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_query_filter_outer_joins.py +6 -6
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_query_filter_rel_outer_joins.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_query_filters.py +4 -4
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_soft_delete_shapes.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_tenant_dml.py +3 -3
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_tenant_shapes.py +3 -3
- simple_module_db-0.0.49/tests/test_db_lease_lock_wait.py +0 -39
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/.gitignore +0 -0
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/LICENSE +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/admission.py +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/callbacks.py +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/engine_options.py +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/provider.py +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/models}/base.py +0 -0
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/simple_module_db/py.typed +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/queries}/search.py +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/schema}/_sqlite_index_compare.py +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/schema}/migration_state.py +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/_core_joins.py +0 -0
- {simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/scoping}/_outer_joins.py +0 -0
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_alembic_project.py +0 -0
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/_scope_inheritance_models.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/auditing}/test_db_bulk_audit_targets.py +0 -0
- {simple_module_db-0.0.49 → simple_module_db-0.0.50}/tests/conftest.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_independent_checkpoint.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_db_savepoint_callbacks.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/engine}/test_independent_session.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/queries}/test_db_pagination.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_custom_scope_registration.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_custom_scope_relationships.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_custom_scope_writes.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_custom_scopes.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_default_tenant.py +0 -0
- {simple_module_db-0.0.49/tests → simple_module_db-0.0.50/tests/scoping}/test_tenant_strict.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_db
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.50
|
|
4
4
|
Summary: Per-module SQLModel Base, async session, standard mixins (Audit, SoftDelete, MultiTenant, Versioned) for simple_module
|
|
5
5
|
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
@@ -25,9 +25,9 @@ Requires-Dist: aiosqlite<0.23,>=0.20
|
|
|
25
25
|
Requires-Dist: alembic<2,>=1.16.3
|
|
26
26
|
Requires-Dist: asyncpg<0.33,>=0.30
|
|
27
27
|
Requires-Dist: psycopg2-binary<3,>=2.9
|
|
28
|
-
Requires-Dist: simple-module-core==0.0.
|
|
28
|
+
Requires-Dist: simple-module-core==0.0.50
|
|
29
29
|
Requires-Dist: sqlalchemy[asyncio]<3,>=2.0.2
|
|
30
|
-
Requires-Dist: sqlmodel<0.1,>=0.0.
|
|
30
|
+
Requires-Dist: sqlmodel<0.1,>=0.0.45
|
|
31
31
|
Description-Content-Type: text/markdown
|
|
32
32
|
|
|
33
33
|
# simple_module_db
|
|
@@ -45,7 +45,7 @@ pip install simple_module_db
|
|
|
45
45
|
- `create_module_base("<module_name>")` — a module-scoped declarative `Base` with its own `MetaData`. All modules share the host's single schema, so `__tablename__` should be prefixed with the module name (e.g. `users_user`) to avoid collisions.
|
|
46
46
|
- Per-request `RequestSession` (`get_db`) that commits pending writes before the response and rolls back read-only requests.
|
|
47
47
|
- `session.on_commit(callback)` for synchronous or asynchronous cache refreshes that must only run after a successful request commit.
|
|
48
|
-
- Mixins in `simple_module_db.mixins`: `AuditMixin` (created_at/updated_at), `SoftDeleteMixin` (auto-filtered unless `stmt.execution_options(include_deleted=True)`), `MultiTenantMixin`, `VersionedMixin`.
|
|
48
|
+
- Mixins in `simple_module_db.models.mixins`: `AuditMixin` (created_at/updated_at), `SoftDeleteMixin` (auto-filtered unless `stmt.execution_options(include_deleted=True)`), `MultiTenantMixin`, `VersionedMixin`.
|
|
49
49
|
- `DatabaseState` container used by the framework to avoid global mutable state.
|
|
50
50
|
|
|
51
51
|
## Usage
|
|
@@ -13,7 +13,7 @@ pip install simple_module_db
|
|
|
13
13
|
- `create_module_base("<module_name>")` — a module-scoped declarative `Base` with its own `MetaData`. All modules share the host's single schema, so `__tablename__` should be prefixed with the module name (e.g. `users_user`) to avoid collisions.
|
|
14
14
|
- Per-request `RequestSession` (`get_db`) that commits pending writes before the response and rolls back read-only requests.
|
|
15
15
|
- `session.on_commit(callback)` for synchronous or asynchronous cache refreshes that must only run after a successful request commit.
|
|
16
|
-
- Mixins in `simple_module_db.mixins`: `AuditMixin` (created_at/updated_at), `SoftDeleteMixin` (auto-filtered unless `stmt.execution_options(include_deleted=True)`), `MultiTenantMixin`, `VersionedMixin`.
|
|
16
|
+
- Mixins in `simple_module_db.models.mixins`: `AuditMixin` (created_at/updated_at), `SoftDeleteMixin` (auto-filtered unless `stmt.execution_options(include_deleted=True)`), `MultiTenantMixin`, `VersionedMixin`.
|
|
17
17
|
- `DatabaseState` container used by the framework to avoid global mutable state.
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_db"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.50"
|
|
4
4
|
description = "Per-module SQLModel Base, async session, standard mixins (Audit, SoftDelete, MultiTenant, Versioned) for simple_module"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -28,9 +28,9 @@ dependencies = [
|
|
|
28
28
|
# The async app code goes through asyncpg; migration env.py rewrites the
|
|
29
29
|
# URL to +psycopg2 because Alembic's online migrations are sync-only.
|
|
30
30
|
"psycopg2-binary>=2.9,<3",
|
|
31
|
-
"simple_module_core==0.0.
|
|
31
|
+
"simple_module_core==0.0.50",
|
|
32
32
|
"sqlalchemy[asyncio]>=2.0.2,<3",
|
|
33
|
-
"sqlmodel>=0.0.
|
|
33
|
+
"sqlmodel>=0.0.45,<0.1",
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
[project.urls]
|
|
@@ -1,33 +1,45 @@
|
|
|
1
1
|
"""SimpleModule DB — async SQLAlchemy/SQLModel runtime shared by every module."""
|
|
2
2
|
|
|
3
|
-
from simple_module_db.audit import AuditRecord
|
|
4
|
-
from simple_module_db.
|
|
5
|
-
from simple_module_db.
|
|
6
|
-
from simple_module_db.
|
|
7
|
-
from simple_module_db.
|
|
8
|
-
from simple_module_db.
|
|
9
|
-
from simple_module_db.
|
|
10
|
-
from simple_module_db.
|
|
11
|
-
from simple_module_db.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
from simple_module_db.auditing.audit import AuditRecord
|
|
4
|
+
from simple_module_db.auditing.bulk_audit import UnauditedWriteError, record_bulk_audit
|
|
5
|
+
from simple_module_db.engine.callbacks import OnCommitCallback
|
|
6
|
+
from simple_module_db.engine.deps import get_db
|
|
7
|
+
from simple_module_db.engine.independent import independent_session
|
|
8
|
+
from simple_module_db.engine.provider import DatabaseProvider, detect_provider
|
|
9
|
+
from simple_module_db.engine.session import DatabaseState, RequestSession, init_db
|
|
10
|
+
from simple_module_db.engine.transaction import CommitBeforeResponseMiddleware, finalize_session
|
|
11
|
+
from simple_module_db.engine.writes import hard_delete, mark_written
|
|
12
|
+
from simple_module_db.models.base import create_module_base
|
|
13
|
+
from simple_module_db.models.extensions import UnsupportedDatabaseError, ensure_db_extensions
|
|
14
|
+
from simple_module_db.models.mixins import (
|
|
15
|
+
AuditMixin,
|
|
16
|
+
MultiTenantMixin,
|
|
17
|
+
SoftDeleteMixin,
|
|
18
|
+
VersionedMixin,
|
|
16
19
|
)
|
|
17
|
-
from simple_module_db.
|
|
18
|
-
from simple_module_db.pagination import (
|
|
20
|
+
from simple_module_db.models.types import AwareDateTime, LTree, TSVector
|
|
21
|
+
from simple_module_db.queries.pagination import (
|
|
19
22
|
Page,
|
|
20
23
|
PageParams,
|
|
21
24
|
clamp_page,
|
|
22
25
|
paginate,
|
|
23
26
|
total_pages,
|
|
24
27
|
)
|
|
25
|
-
from simple_module_db.principals import principal_for
|
|
26
|
-
from simple_module_db.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
from simple_module_db.queries.principals import principal_for
|
|
29
|
+
from simple_module_db.queries.search import (
|
|
30
|
+
LIKE_ESCAPE_CHAR,
|
|
31
|
+
like_contains_pattern,
|
|
32
|
+
like_prefix_pattern,
|
|
33
|
+
)
|
|
34
|
+
from simple_module_db.schema.migration_portability import drop_enums_if_postgres
|
|
35
|
+
from simple_module_db.schema.migrations import (
|
|
36
|
+
build_module_metadata,
|
|
37
|
+
make_include_object,
|
|
38
|
+
make_process_revision_directives,
|
|
39
|
+
render_item,
|
|
40
|
+
)
|
|
41
|
+
from simple_module_db.scoping.scopes import ScopeFilter, ScopeIsolationError, register_scope
|
|
42
|
+
from simple_module_db.scoping.tenancy import (
|
|
31
43
|
ALL_TENANTS_OPTION,
|
|
32
44
|
DEFAULT_TENANT_ID,
|
|
33
45
|
PLATFORM_TENANT_ID,
|
|
@@ -41,9 +53,6 @@ from simple_module_db.tenancy import (
|
|
|
41
53
|
no_tenant,
|
|
42
54
|
tenant_context,
|
|
43
55
|
)
|
|
44
|
-
from simple_module_db.transaction import CommitBeforeResponseMiddleware, finalize_session
|
|
45
|
-
from simple_module_db.types import AwareDateTime, LTree, TSVector
|
|
46
|
-
from simple_module_db.writes import hard_delete, mark_written
|
|
47
56
|
|
|
48
57
|
__all__ = [
|
|
49
58
|
"ALL_TENANTS_OPTION",
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_db.scoping._core_walk."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_db._core_walk",
|
|
10
|
+
remove_in="0.0.52",
|
|
11
|
+
use="simple_module_db.scoping._core_walk",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_db.scoping._core_walk")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_db.engine.admission."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_db.admission",
|
|
10
|
+
remove_in="0.0.52",
|
|
11
|
+
use="simple_module_db.engine.admission",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_db.engine.admission")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_db.auditing.audit."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_db.audit",
|
|
10
|
+
remove_in="0.0.52",
|
|
11
|
+
use="simple_module_db.auditing.audit",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_db.auditing.audit")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_db.auditing.audit_sinks."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_db.audit_sinks",
|
|
10
|
+
remove_in="0.0.52",
|
|
11
|
+
use="simple_module_db.auditing.audit_sinks",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_db.auditing.audit_sinks")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Database auditing area."""
|
|
@@ -6,15 +6,20 @@ import logging
|
|
|
6
6
|
from collections.abc import Iterable
|
|
7
7
|
from typing import Any, Final
|
|
8
8
|
|
|
9
|
-
from simple_module_core.correlation import correlation_id
|
|
9
|
+
from simple_module_core.runtime.correlation import correlation_id
|
|
10
10
|
from sqlalchemy import inspect as sa_inspect
|
|
11
11
|
from sqlalchemy.orm import ORMExecuteState, Session
|
|
12
12
|
|
|
13
|
-
from simple_module_db.audit import AuditRecord, _excluded_fields, _serialize, format_pk
|
|
14
|
-
from simple_module_db.audit_redaction import
|
|
15
|
-
|
|
13
|
+
from simple_module_db.auditing.audit import AuditRecord, _excluded_fields, _serialize, format_pk
|
|
14
|
+
from simple_module_db.auditing.audit_redaction import (
|
|
15
|
+
model_for_audit,
|
|
16
|
+
redact_changes,
|
|
17
|
+
redact_entity_id,
|
|
18
|
+
)
|
|
19
|
+
from simple_module_db.models.credential import current_auth_kind, current_token_id
|
|
20
|
+
from simple_module_db.scoping.query_filter import engine_policy
|
|
16
21
|
|
|
17
|
-
logger = logging.getLogger("simple_module_db.bulk_audit")
|
|
22
|
+
logger = logging.getLogger("simple_module_db.auditing.bulk_audit")
|
|
18
23
|
|
|
19
24
|
ACTION_BULK_INSERTED: Final = "bulk_inserted"
|
|
20
25
|
ACTION_BULK_UPDATED: Final = "bulk_updated"
|
|
@@ -45,6 +50,7 @@ class _Ctx:
|
|
|
45
50
|
self.changes = changes
|
|
46
51
|
self.user_id = _current_user()
|
|
47
52
|
self.correlation_id = correlation_id.get("") or None
|
|
53
|
+
self.auth_kind, self.token_id = current_auth_kind.get(), current_token_id.get()
|
|
48
54
|
|
|
49
55
|
def record(
|
|
50
56
|
self,
|
|
@@ -63,11 +69,13 @@ class _Ctx:
|
|
|
63
69
|
changes=self.changes if changes is None else changes,
|
|
64
70
|
user_id=self.user_id,
|
|
65
71
|
correlation_id=self.correlation_id,
|
|
72
|
+
auth_kind=self.auth_kind,
|
|
73
|
+
token_id=self.token_id,
|
|
66
74
|
)
|
|
67
75
|
|
|
68
76
|
|
|
69
77
|
def _current_user() -> str | None:
|
|
70
|
-
from simple_module_db.listeners import current_user_id
|
|
78
|
+
from simple_module_db.models.listeners import current_user_id
|
|
71
79
|
|
|
72
80
|
return current_user_id.get()
|
|
73
81
|
|
|
@@ -19,7 +19,7 @@ from sqlalchemy import and_
|
|
|
19
19
|
from sqlalchemy.orm import ORMExecuteState
|
|
20
20
|
from sqlalchemy.orm.evaluator import UnevaluatableError, _EvaluatorCompiler
|
|
21
21
|
|
|
22
|
-
from simple_module_db.insert_guard import _param_rows
|
|
22
|
+
from simple_module_db.scoping.insert_guard import _param_rows
|
|
23
23
|
|
|
24
24
|
_NO_SYNC = (False, None)
|
|
25
25
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Primary-key rendering shared by audit capture and its readers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
import uuid
|
|
7
|
+
|
|
8
|
+
_UUID_PK_PART = r"UUID\('([^']+)'\)"
|
|
9
|
+
_UUID_COMPOSITE_PK = re.compile(rf"\({_UUID_PK_PART}(?:, {_UUID_PK_PART})+\)")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def format_pk(values: tuple | list) -> str:
|
|
13
|
+
"""One primary-key rendering for ``entity_id``: bare value, or a tuple string."""
|
|
14
|
+
if len(values) == 1:
|
|
15
|
+
return str(values[0]) if values[0] is not None else ""
|
|
16
|
+
return str(tuple(values))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def parse_uuid_pk(value: str) -> tuple[uuid.UUID, ...] | None:
|
|
20
|
+
"""Read composite UUID keys from ``format_pk``; unsupported ids return None."""
|
|
21
|
+
if _UUID_COMPOSITE_PK.fullmatch(value) is None:
|
|
22
|
+
return None
|
|
23
|
+
try:
|
|
24
|
+
return tuple(uuid.UUID(part) for part in re.findall(_UUID_PK_PART, value))
|
|
25
|
+
except ValueError:
|
|
26
|
+
return None
|
|
@@ -22,9 +22,13 @@ from typing import Any
|
|
|
22
22
|
|
|
23
23
|
from sqlalchemy import inspect as sa_inspect
|
|
24
24
|
from sqlalchemy.orm import Session
|
|
25
|
+
from sqlalchemy.sql.elements import ClauseElement
|
|
25
26
|
|
|
26
|
-
from simple_module_db.
|
|
27
|
-
from simple_module_db.
|
|
27
|
+
from simple_module_db.auditing._pk import format_pk as format_pk
|
|
28
|
+
from simple_module_db.auditing._pk import parse_uuid_pk as parse_uuid_pk
|
|
29
|
+
from simple_module_db.auditing.audit_redaction import redact_changes, redact_entity_id
|
|
30
|
+
from simple_module_db.models.credential import current_auth_kind, current_token_id
|
|
31
|
+
from simple_module_db.models.mixins import SoftDeleteMixin
|
|
28
32
|
|
|
29
33
|
# Fields injected by AuditMixin — always excluded from change diffs
|
|
30
34
|
# because they are bookkeeping, not business data.
|
|
@@ -49,6 +53,8 @@ class AuditRecord:
|
|
|
49
53
|
changes: list[dict[str, Any]] = field(default_factory=list)
|
|
50
54
|
user_id: str | None = None
|
|
51
55
|
correlation_id: str | None = None
|
|
56
|
+
auth_kind: str | None = None
|
|
57
|
+
token_id: str | None = None
|
|
52
58
|
|
|
53
59
|
|
|
54
60
|
@dataclass(frozen=True, slots=True)
|
|
@@ -66,11 +72,8 @@ class _PendingChange:
|
|
|
66
72
|
changes: list[dict[str, Any]]
|
|
67
73
|
user_id: str | None
|
|
68
74
|
correlation_id: str | None
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
# ---------------------------------------------------------------------------
|
|
72
|
-
# Helpers
|
|
73
|
-
# ---------------------------------------------------------------------------
|
|
75
|
+
auth_kind: str | None = None
|
|
76
|
+
token_id: str | None = None
|
|
74
77
|
|
|
75
78
|
|
|
76
79
|
def _is_excluded(obj: object) -> bool:
|
|
@@ -84,11 +87,8 @@ def _excluded_fields(obj: object) -> frozenset[str]:
|
|
|
84
87
|
return _EXCLUDED_MIXIN_FIELDS | per_model
|
|
85
88
|
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if len(values) == 1:
|
|
90
|
-
return str(values[0]) if values[0] is not None else ""
|
|
91
|
-
return str(tuple(values))
|
|
90
|
+
#: Recorded as the new value when an update assigns a SQL expression.
|
|
91
|
+
COMPUTED_BY_DATABASE = "<computed by database>"
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
def _entity_pk_str(obj: object) -> str:
|
|
@@ -130,15 +130,15 @@ def _column_diffs(obj: object, inspector: Any, excl: frozenset[str]) -> list[dic
|
|
|
130
130
|
continue
|
|
131
131
|
old_val = hist.deleted[0] if hist.deleted else None
|
|
132
132
|
new_val = hist.added[0] if hist.added else None
|
|
133
|
-
|
|
133
|
+
# The expression is input to the database, not the value it will store:
|
|
134
|
+
# keep the field (a session_version bump is a revocation worth auditing)
|
|
135
|
+
# but record a marker instead of SQL text.
|
|
136
|
+
is_expression = isinstance(new_val, ClauseElement) or hasattr(new_val, "__clause_element__")
|
|
137
|
+
new = COMPUTED_BY_DATABASE if is_expression else _serialize(new_val)
|
|
138
|
+
changes.append({"field": col_name, "old": _serialize(old_val), "new": new})
|
|
134
139
|
return redact_changes(type(obj), changes, obj)
|
|
135
140
|
|
|
136
141
|
|
|
137
|
-
# ---------------------------------------------------------------------------
|
|
138
|
-
# Two-phase capture
|
|
139
|
-
# ---------------------------------------------------------------------------
|
|
140
|
-
|
|
141
|
-
|
|
142
142
|
def snapshot_changes(
|
|
143
143
|
session: Session,
|
|
144
144
|
user_id: str | None = None,
|
|
@@ -151,6 +151,7 @@ def snapshot_changes(
|
|
|
151
151
|
after flush, so the diff itself must be captured now.
|
|
152
152
|
"""
|
|
153
153
|
pending: list[_PendingChange] = []
|
|
154
|
+
auth_kind, token_id = current_auth_kind.get(), current_token_id.get()
|
|
154
155
|
|
|
155
156
|
excluded_cache: dict[type, frozenset[str]] = {}
|
|
156
157
|
pk_cols_cache: dict[type, set[str]] = {}
|
|
@@ -179,7 +180,10 @@ def snapshot_changes(
|
|
|
179
180
|
for col_name in _column_names(obj):
|
|
180
181
|
if col_name in excl or col_name in pk_cols:
|
|
181
182
|
continue
|
|
182
|
-
|
|
183
|
+
value = getattr(obj, col_name)
|
|
184
|
+
if isinstance(value, ClauseElement) or hasattr(value, "__clause_element__"):
|
|
185
|
+
continue
|
|
186
|
+
changes.append({"field": col_name, "new": _serialize(value)})
|
|
183
187
|
pending.append(
|
|
184
188
|
_PendingChange(
|
|
185
189
|
obj_ref=obj,
|
|
@@ -188,6 +192,8 @@ def snapshot_changes(
|
|
|
188
192
|
changes=redact_changes(type(obj), changes, obj),
|
|
189
193
|
user_id=user_id,
|
|
190
194
|
correlation_id=correlation_id,
|
|
195
|
+
auth_kind=auth_kind,
|
|
196
|
+
token_id=token_id,
|
|
191
197
|
)
|
|
192
198
|
)
|
|
193
199
|
|
|
@@ -210,6 +216,8 @@ def snapshot_changes(
|
|
|
210
216
|
changes=changes,
|
|
211
217
|
user_id=user_id,
|
|
212
218
|
correlation_id=correlation_id,
|
|
219
|
+
auth_kind=auth_kind,
|
|
220
|
+
token_id=token_id,
|
|
213
221
|
)
|
|
214
222
|
)
|
|
215
223
|
continue
|
|
@@ -222,6 +230,8 @@ def snapshot_changes(
|
|
|
222
230
|
changes=changes,
|
|
223
231
|
user_id=user_id,
|
|
224
232
|
correlation_id=correlation_id,
|
|
233
|
+
auth_kind=auth_kind,
|
|
234
|
+
token_id=token_id,
|
|
225
235
|
)
|
|
226
236
|
)
|
|
227
237
|
|
|
@@ -237,6 +247,8 @@ def snapshot_changes(
|
|
|
237
247
|
changes=[],
|
|
238
248
|
user_id=user_id,
|
|
239
249
|
correlation_id=correlation_id,
|
|
250
|
+
auth_kind=auth_kind,
|
|
251
|
+
token_id=token_id,
|
|
240
252
|
)
|
|
241
253
|
)
|
|
242
254
|
|
|
@@ -257,16 +269,13 @@ def finalize_records(pending: list[_PendingChange]) -> list[AuditRecord]:
|
|
|
257
269
|
changes=p.changes,
|
|
258
270
|
user_id=p.user_id,
|
|
259
271
|
correlation_id=p.correlation_id,
|
|
272
|
+
auth_kind=p.auth_kind,
|
|
273
|
+
token_id=p.token_id,
|
|
260
274
|
)
|
|
261
275
|
for p in pending
|
|
262
276
|
]
|
|
263
277
|
|
|
264
278
|
|
|
265
|
-
# ---------------------------------------------------------------------------
|
|
266
|
-
# Single-phase public API (used directly by tests / callers with stable PKs)
|
|
267
|
-
# ---------------------------------------------------------------------------
|
|
268
|
-
|
|
269
|
-
|
|
270
279
|
def collect_audit_records(
|
|
271
280
|
session: Session,
|
|
272
281
|
user_id: str | None = None,
|
|
@@ -13,7 +13,7 @@ def model_for_audit(model: type | str) -> type | None:
|
|
|
13
13
|
"""Accept a mapped class or its registered class name; None for unknown names."""
|
|
14
14
|
if isinstance(model, type):
|
|
15
15
|
return model
|
|
16
|
-
from simple_module_db.model_registry import classes_by_table
|
|
16
|
+
from simple_module_db.models.model_registry import classes_by_table
|
|
17
17
|
|
|
18
18
|
return next((cls for cls in classes_by_table.values() if cls.__name__ == model), None)
|
|
19
19
|
|
|
@@ -22,7 +22,7 @@ from importlib.metadata import entry_points
|
|
|
22
22
|
|
|
23
23
|
from sqlalchemy.orm import Session
|
|
24
24
|
|
|
25
|
-
from simple_module_db.audit import AuditRecord
|
|
25
|
+
from simple_module_db.auditing.audit import AuditRecord
|
|
26
26
|
|
|
27
27
|
AUDIT_SINK_ENTRY_POINT_GROUP = "simple_module.audit_sinks"
|
|
28
28
|
|
|
@@ -34,8 +34,7 @@ from sqlalchemy.orm.util import LoaderCriteriaOption
|
|
|
34
34
|
from sqlalchemy.sql.elements import BindParameter
|
|
35
35
|
from sqlalchemy.sql.visitors import iterate
|
|
36
36
|
|
|
37
|
-
from simple_module_db import
|
|
38
|
-
from simple_module_db._bulk_audit_records import ( # noqa: F401 (re-exported)
|
|
37
|
+
from simple_module_db.auditing._bulk_audit_records import ( # noqa: F401 (re-exported)
|
|
39
38
|
_ACTIVE_KEY,
|
|
40
39
|
_SOFT_DELETE_FLAG,
|
|
41
40
|
ACTION_BULK_DELETED,
|
|
@@ -51,11 +50,12 @@ from simple_module_db._bulk_audit_records import ( # noqa: F401 (re-exported)
|
|
|
51
50
|
_summary,
|
|
52
51
|
record_bulk_audit,
|
|
53
52
|
)
|
|
54
|
-
from simple_module_db.audit import _excluded_fields, format_pk
|
|
55
|
-
from simple_module_db.audit_redaction import redact_changes
|
|
56
|
-
from simple_module_db.bulk_audit_targets import _is_set, _shown, _targets
|
|
57
|
-
from simple_module_db.
|
|
58
|
-
from simple_module_db.
|
|
53
|
+
from simple_module_db.auditing.audit import _excluded_fields, format_pk
|
|
54
|
+
from simple_module_db.auditing.audit_redaction import redact_changes
|
|
55
|
+
from simple_module_db.auditing.bulk_audit_targets import _is_set, _shown, _targets
|
|
56
|
+
from simple_module_db.models import model_registry as registry
|
|
57
|
+
from simple_module_db.scoping.query_filter import engine_policy
|
|
58
|
+
from simple_module_db.scoping.scopes import _scopes
|
|
59
59
|
|
|
60
60
|
logger = logging.getLogger(__name__)
|
|
61
61
|
|
|
@@ -149,9 +149,10 @@ def _prefetch_ids(execute_state: ORMExecuteState, cls: type, cap: int) -> list[s
|
|
|
149
149
|
query = select(*cols).options(*criteria).limit(cap + 1)
|
|
150
150
|
if stmt.whereclause is not None:
|
|
151
151
|
query = query.where(stmt.whereclause)
|
|
152
|
-
options = {"include_deleted": True}
|
|
153
|
-
|
|
154
|
-
|
|
152
|
+
options: dict[str, Any] = {"include_deleted": True}
|
|
153
|
+
for scope in _scopes.values():
|
|
154
|
+
if execute_state.execution_options.get(scope.bypass_option):
|
|
155
|
+
options[scope.bypass_option] = True
|
|
155
156
|
rows = execute_state.session.execute(
|
|
156
157
|
query.execution_options(**options),
|
|
157
158
|
_bound_params(
|
|
@@ -15,7 +15,7 @@ from sqlalchemy.orm import ORMExecuteState
|
|
|
15
15
|
from sqlalchemy.sql.elements import BindParameter, ClauseElement, False_
|
|
16
16
|
from sqlalchemy.sql.visitors import iterate
|
|
17
17
|
|
|
18
|
-
from simple_module_db.audit import _serialize
|
|
18
|
+
from simple_module_db.auditing.audit import _serialize
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def _attr_names(cls: type) -> dict[str, str]:
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_db.models.base."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_db.base",
|
|
10
|
+
remove_in="0.0.52",
|
|
11
|
+
use="simple_module_db.models.base",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_db.models.base")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_db.engine.callbacks."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_db.callbacks",
|
|
10
|
+
remove_in="0.0.52",
|
|
11
|
+
use="simple_module_db.engine.callbacks",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_db.engine.callbacks")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_db.scoping.core_scope."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_db.core_scope",
|
|
10
|
+
remove_in="0.0.52",
|
|
11
|
+
use="simple_module_db.scoping.core_scope",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_db.scoping.core_scope")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_db.schema.data_compatibility."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_db.data_compatibility",
|
|
10
|
+
remove_in="0.0.52",
|
|
11
|
+
use="simple_module_db.schema.data_compatibility",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_db.schema.data_compatibility")
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Deprecated alias for simple_module_db.engine.deps."""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from importlib import import_module
|
|
5
|
+
|
|
6
|
+
from simple_module_core.runtime.deprecation import deprecated_module
|
|
7
|
+
|
|
8
|
+
deprecated_module(
|
|
9
|
+
"simple_module_db.deps",
|
|
10
|
+
remove_in="0.0.52",
|
|
11
|
+
use="simple_module_db.engine.deps",
|
|
12
|
+
)
|
|
13
|
+
sys.modules[__name__] = import_module("simple_module_db.engine.deps")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Database engine area."""
|
{simple_module_db-0.0.49/simple_module_db → simple_module_db-0.0.50/simple_module_db/engine}/deps.py
RENAMED
|
@@ -7,8 +7,8 @@ from collections.abc import AsyncGenerator
|
|
|
7
7
|
|
|
8
8
|
from fastapi import Request
|
|
9
9
|
|
|
10
|
-
from simple_module_db.session import RequestSession
|
|
11
|
-
from simple_module_db.transaction import (
|
|
10
|
+
from simple_module_db.engine.session import RequestSession
|
|
11
|
+
from simple_module_db.engine.transaction import (
|
|
12
12
|
SESSION_START_KEY,
|
|
13
13
|
finalize_session,
|
|
14
14
|
register_request_session,
|
|
@@ -24,7 +24,7 @@ async def get_db(request: Request) -> AsyncGenerator[RequestSession, None]:
|
|
|
24
24
|
without expiring loaded objects.
|
|
25
25
|
|
|
26
26
|
The commit itself normally happens in
|
|
27
|
-
:class:`~simple_module_db.transaction.CommitBeforeResponseMiddleware`,
|
|
27
|
+
:class:`~simple_module_db.engine.transaction.CommitBeforeResponseMiddleware`,
|
|
28
28
|
which fires while the response is still in the server's hands. The
|
|
29
29
|
finalize below is the fallback for when that middleware isn't in the
|
|
30
30
|
stack, and a no-op when it already ran — FastAPI runs this exit code
|
|
@@ -8,8 +8,8 @@ from typing import Any
|
|
|
8
8
|
|
|
9
9
|
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker
|
|
10
10
|
|
|
11
|
-
from simple_module_db.callbacks import discard_on_commit_callbacks, run_on_commit_callbacks
|
|
12
|
-
from simple_module_db.session import SESSION_FACTORY_KEY, RequestSession
|
|
11
|
+
from simple_module_db.engine.callbacks import discard_on_commit_callbacks, run_on_commit_callbacks
|
|
12
|
+
from simple_module_db.engine.session import SESSION_FACTORY_KEY, RequestSession
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
@asynccontextmanager
|