narabi-orm 0.1.0__tar.gz → 0.2.0__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.
- narabi_orm-0.2.0/.github/workflows/docs.yml +45 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/.gitignore +2 -1
- narabi_orm-0.2.0/AGENTS.md +35 -0
- narabi_orm-0.2.0/CHANGELOG.md +83 -0
- narabi_orm-0.2.0/CONTRIBUTING.md +147 -0
- narabi_orm-0.2.0/DECISIONS.md +203 -0
- narabi_orm-0.2.0/PITCH.md +47 -0
- narabi_orm-0.2.0/PKG-INFO +185 -0
- narabi_orm-0.2.0/README.md +146 -0
- narabi_orm-0.2.0/docs/README.md +33 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/docs/architecture.md +32 -8
- narabi_orm-0.2.0/docs/assets/narabi-mark.svg +21 -0
- narabi_orm-0.2.0/docs/assets/narabi.css +83 -0
- narabi_orm-0.2.0/docs/assets/narabi.svg +5 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/docs/comparisons.md +35 -16
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/docs/fastapi.md +34 -21
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/docs/flask.md +24 -13
- narabi_orm-0.2.0/docs/guides/README.md +31 -0
- narabi_orm-0.2.0/docs/guides/adopt-a-database.md +83 -0
- narabi_orm-0.2.0/docs/guides/console.md +36 -0
- narabi_orm-0.2.0/docs/guides/database-configuration.md +93 -0
- narabi_orm-0.2.0/docs/guides/migrations.md +92 -0
- narabi_orm-0.2.0/docs/guides/optimistic-locking.md +90 -0
- narabi_orm-0.2.0/docs/guides/persistent-enums.md +106 -0
- narabi_orm-0.2.0/docs/guides/privacy.md +54 -0
- narabi_orm-0.2.0/docs/guides/relation-updates.md +48 -0
- narabi_orm-0.2.0/docs/guides/reports-and-projections.md +112 -0
- narabi_orm-0.2.0/docs/guides/table-names.md +65 -0
- narabi_orm-0.2.0/docs/guides/testing.md +40 -0
- narabi_orm-0.2.0/docs/guides/transactions.md +41 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/docs/reference.md +225 -165
- narabi_orm-0.2.0/docs/tutorial/01-setup.md +34 -0
- narabi_orm-0.2.0/docs/tutorial/02-models-and-naming.md +53 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/docs/tutorial/03-first-book.md +35 -21
- narabi_orm-0.2.0/docs/tutorial/04-queries.md +56 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/docs/tutorial/05-authors.md +65 -36
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/docs/tutorial/06-orders.md +31 -23
- narabi_orm-0.2.0/docs/tutorial/07-privacy.md +60 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/docs/tutorial/08-console.md +20 -13
- narabi_orm-0.2.0/docs/tutorial.md +21 -0
- narabi_orm-0.2.0/examples/README.md +164 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/library_lending/README.md +24 -20
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/maintenance_api/README.md +25 -21
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/order_import/README.md +4 -3
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/aggregates/README.md +8 -5
- narabi_orm-0.2.0/examples/features/async_console/README.md +22 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/change_tracking/README.md +10 -6
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/database_configuration/README.md +8 -5
- narabi_orm-0.2.0/examples/features/defaults/README.md +16 -0
- narabi_orm-0.2.0/examples/features/diagnostics/README.md +22 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/eager_loading/README.md +8 -5
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/filtering/README.md +6 -4
- narabi_orm-0.2.0/examples/features/historical_data/README.md +16 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/lifecycle_hooks/README.md +10 -6
- narabi_orm-0.2.0/examples/features/migration_apply/README.md +23 -0
- narabi_orm-0.2.0/examples/features/migration_generation/README.md +23 -0
- narabi_orm-0.2.0/examples/features/migration_rollback/README.md +21 -0
- narabi_orm-0.2.0/examples/features/migration_safety/README.md +26 -0
- narabi_orm-0.2.0/examples/features/offline_replay/README.md +20 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/pagination/README.md +6 -4
- narabi_orm-0.2.0/examples/features/persistence/README.md +16 -0
- narabi_orm-0.2.0/examples/features/persistent_enums/README.md +15 -0
- narabi_orm-0.2.0/examples/features/persistent_enums/app.py +80 -0
- narabi_orm-0.2.0/examples/features/privacy/README.md +16 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/privacy_inventory/README.md +11 -7
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/pytest_fixture/README.md +10 -6
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/query_projection/README.md +6 -4
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/relationships/README.md +8 -5
- narabi_orm-0.2.0/examples/features/reports_and_projections/README.md +17 -0
- narabi_orm-0.2.0/examples/features/reports_and_projections/app.py +63 -0
- narabi_orm-0.2.0/examples/features/reports_and_projections/migrations/000001_sales.py +17 -0
- narabi_orm-0.2.0/examples/features/reports_and_projections/models.py +25 -0
- narabi_orm-0.2.0/examples/features/reports_and_projections/pyproject.toml +18 -0
- narabi_orm-0.2.0/examples/features/schema_drift/README.md +22 -0
- narabi_orm-0.2.0/examples/features/scopes/README.md +16 -0
- narabi_orm-0.2.0/examples/features/seeding/README.md +21 -0
- narabi_orm-0.2.0/examples/features/serialization/README.md +16 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/soft_deletion/README.md +10 -6
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/timestamps/README.md +8 -5
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/transactions/README.md +6 -4
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/typing_stubs/README.md +11 -7
- narabi_orm-0.2.0/examples/features/validation/README.md +16 -0
- narabi_orm-0.2.0/mise.toml +3 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/__init__.py +3 -1
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/cli.py +70 -7
- narabi_orm-0.2.0/narabi/database.py +475 -0
- narabi_orm-0.2.0/narabi/migrations/catalog.py +176 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/dsl.py +33 -7
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/executor.py +7 -1
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/generate.py +11 -3
- narabi_orm-0.2.0/narabi/migrations/infer.py +121 -0
- narabi_orm-0.2.0/narabi/migrations/lookup.py +79 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/models.py +47 -3
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/postgres_executor.py +10 -5
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/postgresql.py +13 -6
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/preview.py +7 -3
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/reverse.py +5 -1
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/schema.py +44 -1
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/sqlite.py +9 -7
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/bulk.py +12 -4
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/core.py +58 -18
- narabi_orm-0.2.0/narabi/models/enums.py +98 -0
- narabi_orm-0.2.0/narabi/models/inflection.py +71 -0
- narabi_orm-0.2.0/narabi/models/optimistic.py +26 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/serialization.py +4 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/soft_delete.py +21 -4
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/validation.py +2 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/values.py +1 -1
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/project.py +7 -3
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/query/expressions.py +43 -1
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/query/relation.py +150 -49
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/schema.py +21 -1
- narabi_orm-0.2.0/narabi.svg +5 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/pyproject.toml +5 -2
- narabi_orm-0.2.0/tests/feasibility/README.md +51 -0
- narabi_orm-0.2.0/tests/test_migration_defaults.py +92 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_dsl.py +26 -1
- narabi_orm-0.2.0/tests/test_optimistic_locking.py +158 -0
- narabi_orm-0.2.0/tests/test_persistent_enums.py +140 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_postgresql_drift.py +11 -11
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_postgresql_executor.py +3 -3
- narabi_orm-0.2.0/tests/test_relation_update.py +108 -0
- narabi_orm-0.2.0/tests/test_schema_infer.py +138 -0
- narabi_orm-0.2.0/tests/test_sqlite_settings.py +141 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_transactions.py +154 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/uv.lock +324 -1
- narabi_orm-0.2.0/zensical.toml +107 -0
- narabi_orm-0.1.0/AGENTS.md +0 -10
- narabi_orm-0.1.0/CONTRIBUTING.md +0 -26
- narabi_orm-0.1.0/PITCH.md +0 -19
- narabi_orm-0.1.0/PKG-INFO +0 -104
- narabi_orm-0.1.0/README.md +0 -65
- narabi_orm-0.1.0/docs/README.md +0 -12
- narabi_orm-0.1.0/docs/guides.md +0 -206
- narabi_orm-0.1.0/docs/tutorial/01-setup.md +0 -21
- narabi_orm-0.1.0/docs/tutorial/02-models-and-naming.md +0 -36
- narabi_orm-0.1.0/docs/tutorial/04-queries.md +0 -41
- narabi_orm-0.1.0/docs/tutorial/07-privacy.md +0 -51
- narabi_orm-0.1.0/docs/tutorial.md +0 -16
- narabi_orm-0.1.0/examples/README.md +0 -126
- narabi_orm-0.1.0/examples/features/async_console/README.md +0 -17
- narabi_orm-0.1.0/examples/features/defaults/README.md +0 -12
- narabi_orm-0.1.0/examples/features/diagnostics/README.md +0 -17
- narabi_orm-0.1.0/examples/features/historical_data/README.md +0 -12
- narabi_orm-0.1.0/examples/features/migration_apply/README.md +0 -17
- narabi_orm-0.1.0/examples/features/migration_generation/README.md +0 -17
- narabi_orm-0.1.0/examples/features/migration_rollback/README.md +0 -17
- narabi_orm-0.1.0/examples/features/migration_safety/README.md +0 -19
- narabi_orm-0.1.0/examples/features/offline_replay/README.md +0 -17
- narabi_orm-0.1.0/examples/features/persistence/README.md +0 -12
- narabi_orm-0.1.0/examples/features/privacy/README.md +0 -12
- narabi_orm-0.1.0/examples/features/schema_drift/README.md +0 -17
- narabi_orm-0.1.0/examples/features/scopes/README.md +0 -12
- narabi_orm-0.1.0/examples/features/seeding/README.md +0 -17
- narabi_orm-0.1.0/examples/features/serialization/README.md +0 -12
- narabi_orm-0.1.0/examples/features/validation/README.md +0 -12
- narabi_orm-0.1.0/narabi/database.py +0 -310
- narabi_orm-0.1.0/narabi/models/inflection.py +0 -37
- narabi_orm-0.1.0/tests/feasibility/README.md +0 -44
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/.github/workflows/examples.yml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/.github/workflows/publish.yml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/.github/workflows/tests.yml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/LICENSE +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/library_lending/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/library_lending/catalog_locations.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/library_lending/initial_migration.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/library_lending/postgresql.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/library_lending/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/maintenance_api/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/maintenance_api/demo.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/maintenance_api/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/order_import/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/domain/order_import/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/_support.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/aggregates/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/async_console/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/async_console/migrations/000001_initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/async_console/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/async_console/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/async_console/seed_data.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/change_tracking/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/database_configuration/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/defaults/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/diagnostics/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/diagnostics/migrations/000001_initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/diagnostics/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/diagnostics/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/eager_loading/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/filtering/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/historical_data/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/historical_data/initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/lifecycle_hooks/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_apply/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_apply/migrations/000001_initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_apply/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_apply/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_generation/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_generation/migrations/000001_initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_generation/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_generation/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_rollback/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_rollback/migrations/000001_initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_rollback/migrations/000002_add_note.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_rollback/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_rollback/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_rollback/seed_data.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_safety/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_safety/migrations/000001_initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_safety/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_safety/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/migration_safety/review/000002_drop.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/offline_replay/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/offline_replay/migrations/000001_initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/offline_replay/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/offline_replay/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/pagination/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/persistence/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/privacy/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/privacy_inventory/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/privacy_inventory/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/privacy_inventory/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/pytest_fixture/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/pytest_fixture/fixture_demo.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/query_projection/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/relationships/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/schema_drift/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/schema_drift/migrations/000001_initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/schema_drift/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/schema_drift/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/scopes/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/seeding/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/seeding/migrations/000001_initial.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/seeding/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/seeding/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/seeding/seed_data.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/serialization/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/soft_deletion/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/timestamps/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/transactions/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/typing_stubs/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/typing_stubs/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/typing_stubs/pyproject.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/features/validation/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/toml_schema/app.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/toml_schema/demo.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/examples/toml_schema/schema.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/__main__.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/console.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/fields/__init__.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/fields/defaults.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/fields/markers.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/__init__.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/bootstrap.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/decorators.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/diff.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/errors.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/historical.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/history.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/replay.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/migrations/snapshot.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/__init__.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/lifecycle.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/privacy.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/models/timestamps.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/py.typed +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/pytest.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/query/__init__.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/query/scopes.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/relations/__init__.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/relations/prefetch.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/relations/references.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/relations/relationships.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi/stubs.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/narabi.toml +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/feasibility/__init__.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/feasibility/check_typing.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/feasibility/models.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/feasibility/prototype.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/feasibility/test_runtime.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_bulk.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_cli.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_console.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_defaults.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_fastapi_guide.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_feature_examples.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_integration.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_library_migration.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_lifecycle.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_data.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_diff.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_drift.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_executor.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_generation.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_history.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_locking.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_replay.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_rollback.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_migration_schema.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_persistence_state.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_postgresql_migrations.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_postgresql_pool.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_privacy.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_records.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_references.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_relations.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_schema_bootstrap.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_serialization.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_soft_delete.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_stubs.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_validation.py +0 -0
- {narabi_orm-0.1.0 → narabi_orm-0.2.0}/tests/test_values.py +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
name: Documentation
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches: [main]
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
name: Build documentation
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v6
|
|
18
|
+
- uses: actions/setup-python@v6
|
|
19
|
+
with:
|
|
20
|
+
python-version: '3.12'
|
|
21
|
+
- uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
|
22
|
+
- run: uv run --locked --only-group docs zensical build --strict
|
|
23
|
+
- uses: actions/upload-pages-artifact@v5
|
|
24
|
+
if: github.ref == 'refs/heads/main'
|
|
25
|
+
with:
|
|
26
|
+
path: site
|
|
27
|
+
|
|
28
|
+
deploy:
|
|
29
|
+
name: Publish to GitHub Pages
|
|
30
|
+
if: github.ref == 'refs/heads/main'
|
|
31
|
+
needs: build
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
permissions:
|
|
34
|
+
pages: write
|
|
35
|
+
id-token: write
|
|
36
|
+
concurrency:
|
|
37
|
+
group: github-pages
|
|
38
|
+
cancel-in-progress: false
|
|
39
|
+
environment:
|
|
40
|
+
name: github-pages
|
|
41
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/configure-pages@v6
|
|
44
|
+
- uses: actions/deploy-pages@v5
|
|
45
|
+
id: deployment
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Working on Narabi
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
- Use **Narabi** for the project, `narabi` for the import and CLI, and
|
|
5
|
+
`narabi-orm` for the distribution. Support standalone `narabi.toml` and
|
|
6
|
+
`[tool.narabi]` in `pyproject.toml` as peer choices.
|
|
7
|
+
- Keep models, queries, migrations, and privacy in core. SQLite, PostgreSQL,
|
|
8
|
+
and IPython are optional. Load their dependencies at the point of use and
|
|
9
|
+
keep clean-wheel checks current.
|
|
10
|
+
- Prefer readable code that earns its place. Reuse existing behavior, keep
|
|
11
|
+
transaction boundaries explicit, and avoid adding abstractions for
|
|
12
|
+
hypothetical callers.
|
|
13
|
+
- Use Python and `uv`. Teach project setup with `uv add` and `uv run`. Use
|
|
14
|
+
the PyPI distribution in user-facing setup and reserve checkout
|
|
15
|
+
instructions for contributors and repository examples. Let Narabi select
|
|
16
|
+
the configured database unless an example needs an explicit handle. Read
|
|
17
|
+
the manifest and CI workflows before changing commands. Test through the
|
|
18
|
+
same public entry point that exposed the problem and run the applicable
|
|
19
|
+
backend checks.
|
|
20
|
+
- Show the conventional API first. Keep the README a showcase and teach
|
|
21
|
+
with progressive, runnable examples in `docs/`. Write short, task-focused
|
|
22
|
+
guides with code, output, and diagrams where they explain a workflow.
|
|
23
|
+
Compare libraries respectfully and verify capability claims.
|
|
24
|
+
- Work in milestone and priority order, accounting for dependencies.
|
|
25
|
+
Use one PR per issue and one coherent change per commit. Use `gh` for
|
|
26
|
+
GitHub work and `gh stack` for stacked PRs. Start from updated `main` after
|
|
27
|
+
the previous stack merges.
|
|
28
|
+
- Explain the behavior and decisions in the PR with code, tables, or CLI
|
|
29
|
+
output. Report verification and skipped checks in chat before submitting.
|
|
30
|
+
Use the existing local environment and cache. When asked to fix or
|
|
31
|
+
monitor CI, follow the relevant checks through completion.
|
|
32
|
+
|
|
33
|
+
See <CONTRIBUTING.md> for the writing and review guide,
|
|
34
|
+
[architecture](docs/architecture.md) for how the code fits together, and
|
|
35
|
+
<DECISIONS.md> for the reasons behind specific choices.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Changelog
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
0.2.0 · 2026-12-03
|
|
5
|
+
------------------
|
|
6
|
+
|
|
7
|
+
Generate models from a database you already have, update matching rows in
|
|
8
|
+
one statement, and opt in to optimistic locking where concurrent edits matter.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Adopt an existing database.** Run `uv run narabi schema infer` to print
|
|
13
|
+
Python models for a live SQLite or PostgreSQL database. Pass
|
|
14
|
+
`--output models.py` to save them. Inference leaves the database and
|
|
15
|
+
migration history untouched. [Adoption guide]
|
|
16
|
+
- **Update matching rows atomically.** Use
|
|
17
|
+
`await Job.where(id=7, status="pending").update(attempts=it.attempts + 1)`
|
|
18
|
+
to increment a counter in SQL and get the number of rows updated. An
|
|
19
|
+
explicit filter is required. Set-based updates bypass model validation
|
|
20
|
+
and lifecycle hooks. [Relation updates]
|
|
21
|
+
- **Detect stale edits.** Set `optimistic_lock=True` on a table model to
|
|
22
|
+
reject saves and deletes based on a stale row version with
|
|
23
|
+
`StaleRecordError`. Generate and apply the migration that adds the
|
|
24
|
+
`version` column before using the updated model. [Optimistic locking]
|
|
25
|
+
- **Store enums with stable IDs.** Decorate a Python enum with `@table` and
|
|
26
|
+
use it as a model field. Narabi stores a foreign key to a shared lookup
|
|
27
|
+
table, so you can change a member's value in a migration while keeping
|
|
28
|
+
its ID. [Persistent enums and backfills]
|
|
29
|
+
- **Configure SQLite durability and locks.** Set `journal_mode = "wal"`,
|
|
30
|
+
`synchronous`, or `busy_timeout_ms` in your database configuration.
|
|
31
|
+
Use `db.transaction(write=True)` on an outer transaction to take the
|
|
32
|
+
writer lock before reading. `uv run narabi doctor` shows the runtime
|
|
33
|
+
version and effective settings. WAL requires a file-backed database
|
|
34
|
+
and a supported SQLite version. [Database configuration]
|
|
35
|
+
|
|
36
|
+
[Adoption guide]: https://rickbarretto.github.io/narabi-orm/guides/adopt-a-database/
|
|
37
|
+
[Relation updates]: https://rickbarretto.github.io/narabi-orm/guides/relation-updates/
|
|
38
|
+
[Optimistic locking]: https://rickbarretto.github.io/narabi-orm/guides/optimistic-locking/
|
|
39
|
+
[Persistent enums and backfills]: https://rickbarretto.github.io/narabi-orm/guides/persistent-enums/
|
|
40
|
+
[Database configuration]: https://rickbarretto.github.io/narabi-orm/guides/database-configuration/
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- Async cancellation now waits for in-flight SQL and transaction cleanup
|
|
45
|
+
to finish before returning a connection. If cancellation interrupts a
|
|
46
|
+
statement, the transaction is marked for rollback.
|
|
47
|
+
- Migrations preserve integer column defaults and restrictive foreign-key
|
|
48
|
+
delete rules.
|
|
49
|
+
|
|
50
|
+
### Documentation
|
|
51
|
+
|
|
52
|
+
The [documentation site] brings
|
|
53
|
+
together installation, the bookstore tutorial, and task-focused guides.
|
|
54
|
+
The [reporting example]
|
|
55
|
+
shows typed query results, grouped SQL totals, and a summary updated in
|
|
56
|
+
the same transaction as the order.
|
|
57
|
+
|
|
58
|
+
[Compare 0.1.0 and 0.2.0]
|
|
59
|
+
|
|
60
|
+
[documentation site]: https://rickbarretto.github.io/narabi-orm/
|
|
61
|
+
[reporting example]: https://rickbarretto.github.io/narabi-orm/guides/reports-and-projections/
|
|
62
|
+
[Compare 0.1.0 and 0.2.0]: https://github.com/RickBarretto/narabi-orm/compare/v0.1.0...v0.2.0
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
0.1.0 · 2026-11-29
|
|
66
|
+
------------------
|
|
67
|
+
|
|
68
|
+
Initial release. Declare async Active Record models with Python type
|
|
69
|
+
annotations and use them with SQLite or PostgreSQL.
|
|
70
|
+
|
|
71
|
+
- Compose queries and load associations through models. Inspect SQL and query
|
|
72
|
+
plans, and opt in to connection pooling for PostgreSQL.
|
|
73
|
+
- Generate editable Python migrations, preview SQL, and export or load
|
|
74
|
+
schema snapshots.
|
|
75
|
+
- Classify model fields with `Personal`, `Sensitive`, and `Private` for
|
|
76
|
+
redacted representations and run `uv run narabi privacy inventory` to
|
|
77
|
+
review classifications.
|
|
78
|
+
- Try queries and writes in the optional IPython console. Use
|
|
79
|
+
`uv run narabi console --sandbox` to roll back writes when you exit.
|
|
80
|
+
|
|
81
|
+
[GitHub release]
|
|
82
|
+
|
|
83
|
+
[GitHub release]: https://github.com/RickBarretto/narabi-orm/releases/tag/v0.1.0
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Contributing to Narabi
|
|
2
|
+
======================
|
|
3
|
+
|
|
4
|
+
Narabi is an async Active Record library for Python. Start with a model,
|
|
5
|
+
query through it, and save through the record you loaded. Prefer readable
|
|
6
|
+
annotations, Rails-style conventions, and explicit transaction boundaries.
|
|
7
|
+
|
|
8
|
+
- [Why Narabi exists](PITCH.md)
|
|
9
|
+
- [How the code fits together](docs/architecture.md)
|
|
10
|
+
- [Decision record](DECISIONS.md)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
Set up the checkout
|
|
14
|
+
-------------------
|
|
15
|
+
|
|
16
|
+
Use Python 3.12 or newer and `uv`.
|
|
17
|
+
|
|
18
|
+
~~~~ sh
|
|
19
|
+
uv sync --locked --no-install-project --extra test --group examples
|
|
20
|
+
uv run --no-sync --with pyright==1.1.408 python -m unittest discover -s tests -v
|
|
21
|
+
~~~~
|
|
22
|
+
|
|
23
|
+
Run the narrowest relevant suite while iterating.
|
|
24
|
+
|
|
25
|
+
~~~~ sh
|
|
26
|
+
uv run --no-sync python -m unittest discover -s tests -p test_transactions.py -v
|
|
27
|
+
~~~~
|
|
28
|
+
|
|
29
|
+
Add `--extra postgres` to synchronization and set `NARABI_TEST_POSTGRES`
|
|
30
|
+
to a disposable PostgreSQL 16 database for live checks.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Follow a change through the code
|
|
34
|
+
--------------------------------
|
|
35
|
+
|
|
36
|
+
| Area | Where to start |
|
|
37
|
+
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
38
|
+
| Model declaration and persistence | `narabi.models.core` turns annotations into model metadata and attaches persistence methods. |
|
|
39
|
+
| Queries and relationships | `narabi.query.relation` compiles immutable relations to SQL and bindings. `narabi.relations` uses the same metadata for references and associations. |
|
|
40
|
+
| Connections and writes | `Database` owns connections, dialect selection, and transaction boundaries. Preserve the distinction between instance writes and set-based writes. |
|
|
41
|
+
| Schema changes | `narabi.migrations.models` reads declarations. Replay reconstructs history, the diff generates editable migrations, and the executor verifies checksums and drift before applying changes. |
|
|
42
|
+
| CLI and project settings | `narabi.cli` delegates to project configuration and public APIs. Drivers and IPython load at point of use. |
|
|
43
|
+
|
|
44
|
+
Take the shortest route through the existing API. Use framework adapters in
|
|
45
|
+
examples and keep framework dependencies out of model code. Prefer a
|
|
46
|
+
set-based backfill when one update can express what changes for every
|
|
47
|
+
matching row. Keep tests near the subsystem they exercise. Use
|
|
48
|
+
`examples/features/` for one capability and `examples/domain/` for a
|
|
49
|
+
workflow that combines several. Give each feature example its setup, run
|
|
50
|
+
command, and visible result.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Write for somebody trying it
|
|
54
|
+
----------------------------
|
|
55
|
+
|
|
56
|
+
| Page | Start with |
|
|
57
|
+
| -------------------------------------- | ------------------------------------------------------------------------------------------------------ |
|
|
58
|
+
| [README](README.md) | A result worth trying, a short example, and a link to the full guide. |
|
|
59
|
+
| [Pitch](PITCH.md) | The problem that made Narabi worth building and the design it led to. |
|
|
60
|
+
| [Tutorial](docs/tutorial.md) | A progressive bookstore project. Each chapter gives the reader something to run and a result to check. |
|
|
61
|
+
| [How-to guides](docs/guides/README.md) | One task per page with short headings, code blocks, and a link to related work. |
|
|
62
|
+
| [API reference](docs/reference.md) | Exact signatures, defaults, return values, and errors. |
|
|
63
|
+
| [Comparisons](docs/comparisons.md) | The same task in each library. Explain the tradeoff respectfully and verify the claim. |
|
|
64
|
+
|
|
65
|
+
- **Show the common path first.** Let Narabi select the configured database.
|
|
66
|
+
Use inferred names when naming conventions are enabled. Reach for an
|
|
67
|
+
explicit name, an explicit `db=`, or a framework lifecycle hook when it
|
|
68
|
+
explains a real choice.
|
|
69
|
+
- **Give readers something to run.** Use `uv add 'narabi-orm[sqlite]'` or the
|
|
70
|
+
matching extra in user-facing setup, followed by `uv run`. Use checkout
|
|
71
|
+
instructions for contributors and repository examples.
|
|
72
|
+
- **Make pages easy to scan.** Use short, direct paragraphs, command and
|
|
73
|
+
output blocks, and tables for choices or outcomes. Use headings that
|
|
74
|
+
match the reader's task, such as “Already have a database?” for adoption.
|
|
75
|
+
Use a callout for constraints the reader needs to notice. Use Mermaid when
|
|
76
|
+
order or branches are easier to see than to describe. Link tutorial
|
|
77
|
+
chapters with Back, Summary, and Next.
|
|
78
|
+
- **Explain behavior with evidence.** Show the declaration, a row or table
|
|
79
|
+
when storage matters, and the result. For CLI behavior, show the command,
|
|
80
|
+
representative output, and the exact error or exit status when relevant.
|
|
81
|
+
Label simulated output. Give a concrete reason for each design choice.
|
|
82
|
+
- **Teach migrations as steps.** Show inference, preview, and apply. Explain
|
|
83
|
+
what `@migrate`, `@transform`, and `@rollback` do and the order they run.
|
|
84
|
+
Name each step for its job, such as `create_authors` and
|
|
85
|
+
`add_book_author_reference`. Keep related steps in the same file when
|
|
86
|
+
that helps readers follow the change.
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
Preview the documentation
|
|
90
|
+
-------------------------
|
|
91
|
+
|
|
92
|
+
Run these commands from the repository root.
|
|
93
|
+
|
|
94
|
+
~~~~ sh
|
|
95
|
+
uv run --locked --only-group docs zensical serve
|
|
96
|
+
uv run --locked --only-group docs zensical build --strict
|
|
97
|
+
~~~~
|
|
98
|
+
|
|
99
|
+
Open <http://localhost:8000/narabi-orm/> for the preview. Keep links between
|
|
100
|
+
pages in `docs/` relative to their Markdown files. Link to GitHub for examples
|
|
101
|
+
and other files outside `docs/`.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
Plan and review changes
|
|
105
|
+
-----------------------
|
|
106
|
+
|
|
107
|
+
1. **Start from the issue.** Follow the GitHub milestone and priority labels,
|
|
108
|
+
then account for dependencies. Check the current branch and PR state.
|
|
109
|
+
After a stack merges, update `main` and start the next stack from there.
|
|
110
|
+
2. **Settle behavior before building.** For a new feature, agree on the
|
|
111
|
+
example a user should be able to run, the table and migration impact,
|
|
112
|
+
errors, and backend differences. Ask about choices that change the
|
|
113
|
+
public contract. Look for related issues and agree on the scope before
|
|
114
|
+
filing a batch.
|
|
115
|
+
3. **Use one PR per issue and one coherent change per commit.** A PR can
|
|
116
|
+
contain several commits. Use short imperative subjects, such as
|
|
117
|
+
`Share relation filter compilation` or `Document atomic relation updates`.
|
|
118
|
+
Use `gh` for GitHub work and `gh stack` for stacked PRs.
|
|
119
|
+
4. **Make the PR useful to a reviewer.** Link the issue. Explain the problem
|
|
120
|
+
with code, schema, or shell examples and give the reason for the design.
|
|
121
|
+
Report test counts and skipped checks in the handoff before submission.
|
|
122
|
+
Keep the PR body focused on behavior and decisions.
|
|
123
|
+
|
|
124
|
+
Write issues in English. Include current behavior, expected behavior, a
|
|
125
|
+
concrete code or CLI example, table implications where relevant, and
|
|
126
|
+
acceptance criteria. Link prerequisites and split broad topics into concrete
|
|
127
|
+
subissues. Use the `open-discussion` label for proposals that need a decision.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
Verify the change
|
|
131
|
+
-----------------
|
|
132
|
+
|
|
133
|
+
Test through the public entry point that exposed the problem. Use the
|
|
134
|
+
existing environment and cache for local checks. Report any missing backend,
|
|
135
|
+
runtime, or optional tool before submission.
|
|
136
|
+
|
|
137
|
+
- Read the [Tests workflow](.github/workflows/tests.yml) for the supported
|
|
138
|
+
checks. For a backend change, cover SQLite and PostgreSQL where applicable.
|
|
139
|
+
- For packaging changes, build with `uv build --wheel` and run the installed
|
|
140
|
+
CLI and smoke checks outside the checkout in core, SQLite, PostgreSQL,
|
|
141
|
+
console, and all environments.
|
|
142
|
+
- Run the affected examples using the
|
|
143
|
+
[Examples workflow](.github/workflows/examples.yml).
|
|
144
|
+
- When asked to fix or monitor CI, follow the affected checks to completion
|
|
145
|
+
and report what passed or remains blocked.
|
|
146
|
+
|
|
147
|
+
Record durable API, schema, or scope decisions in <DECISIONS.md>.
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Narabi decision record
|
|
2
|
+
======================
|
|
3
|
+
|
|
4
|
+
Use this record to understand why a choice was made before changing it.
|
|
5
|
+
The [architecture guide](docs/architecture.md) describes how the parts fit
|
|
6
|
+
together. <CONTRIBUTING.md> describes how to write, test,
|
|
7
|
+
and review a change.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Product boundaries
|
|
11
|
+
------------------
|
|
12
|
+
|
|
13
|
+
### Keep persistence on the model
|
|
14
|
+
|
|
15
|
+
Use ordinary Python annotations and decorators. `@record` provides an
|
|
16
|
+
in-memory record, `@table` adds persistence, and `@value` groups fields
|
|
17
|
+
that belong together. Use `attrs` internally. Prefer inferred names and
|
|
18
|
+
relationship declarations, such as `@has_many` on a typed method.
|
|
19
|
+
|
|
20
|
+
The model should make common work quicker than hand-written SQL.
|
|
21
|
+
`Database.execute()` remains available when SQL is clearer. Application
|
|
22
|
+
code owns orchestration such as shard routing and telemetry integration.
|
|
23
|
+
[Project pitch](PITCH.md) · [Shard resolution proposal] · [Telemetry proposal]
|
|
24
|
+
|
|
25
|
+
[Shard resolution proposal]: https://github.com/RickBarretto/narabi-orm/issues/80
|
|
26
|
+
[Telemetry proposal]: https://github.com/RickBarretto/narabi-orm/issues/79
|
|
27
|
+
|
|
28
|
+
### Keep core small and configuration consistent
|
|
29
|
+
|
|
30
|
+
Keep models, queries, migrations, and privacy in the base package.
|
|
31
|
+
SQLite, PostgreSQL, and IPython are optional dependencies loaded at point
|
|
32
|
+
of use. FastAPI and Flask examples show integration while the ORM works
|
|
33
|
+
independently.
|
|
34
|
+
|
|
35
|
+
Treat standalone `narabi.toml` and `[tool.narabi]` in `pyproject.toml`
|
|
36
|
+
as supported project choices. Use one vocabulary in both. If both files
|
|
37
|
+
declare Narabi in the same directory, the standalone file wins.
|
|
38
|
+
[Database selection #8] ·
|
|
39
|
+
[Database configuration](docs/guides/database-configuration.md)
|
|
40
|
+
|
|
41
|
+
[Database selection #8]: https://github.com/RickBarretto/narabi-orm/issues/8
|
|
42
|
+
|
|
43
|
+
### Keep schema and privacy intent visible
|
|
44
|
+
|
|
45
|
+
Model declarations describe the schema the application expects. Migration
|
|
46
|
+
files describe how to reach it. Generate editable structural changes from a
|
|
47
|
+
diff against replayed history. Keep data transforms and reversals explicit
|
|
48
|
+
so a reviewer can see which rows change. Verify checksums and live drift
|
|
49
|
+
before applying migrations. Build snapshots from migration history so
|
|
50
|
+
database details beyond the model declarations survive.
|
|
51
|
+
|
|
52
|
+
Declare privacy alongside the field. Redact representations, omit
|
|
53
|
+
`Private` fields from default serialization, and use a projection or
|
|
54
|
+
response schema to choose public fields. Treat privacy inventory as
|
|
55
|
+
inspection of declarations.
|
|
56
|
+
|
|
57
|
+
[Migration guide](docs/guides/migrations.md) ·
|
|
58
|
+
[Privacy guide](docs/guides/privacy.md)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
Roadmap and review
|
|
62
|
+
------------------
|
|
63
|
+
|
|
64
|
+
### Sequence work by milestone, priority, and dependency
|
|
65
|
+
|
|
66
|
+
The phases cover production SQLite, concurrency, database management,
|
|
67
|
+
data patterns, and diagnostics, in that order. Use priority labels inside
|
|
68
|
+
each phase and account for cross-phase dependencies. Cancellation safety
|
|
69
|
+
supports the SQLite phase even though it lives in Concurrency.
|
|
70
|
+
|
|
71
|
+
Move a concrete prerequisite or teaching example earlier when it earns
|
|
72
|
+
its place. Reporting moved to Concurrency because the existing query and
|
|
73
|
+
transaction APIs suffice. Enums and JSON moved to Database Management
|
|
74
|
+
because they build on schema tooling. Typed scalar lists still depend on
|
|
75
|
+
portable JSON. The SQLite pooling benchmark was deferred after the
|
|
76
|
+
durability work.
|
|
77
|
+
|
|
78
|
+
[Milestones] · [Reporting #77] · [JSON #26] · [Pooling #75]
|
|
79
|
+
|
|
80
|
+
[Milestones]: https://github.com/RickBarretto/narabi-orm/milestones
|
|
81
|
+
[Reporting #77]: https://github.com/RickBarretto/narabi-orm/issues/77
|
|
82
|
+
[JSON #26]: https://github.com/RickBarretto/narabi-orm/issues/26
|
|
83
|
+
[Pooling #75]: https://github.com/RickBarretto/narabi-orm/issues/75
|
|
84
|
+
|
|
85
|
+
### Teach a workflow people can skim and run
|
|
86
|
+
|
|
87
|
+
Use the Rails Guides approach. The README showcases the API, the
|
|
88
|
+
bookstore tutorial adds one concept at a time, and reference pages give
|
|
89
|
+
the contract. Showcase field privacy and adoption of an existing database
|
|
90
|
+
near the top of the README.
|
|
91
|
+
|
|
92
|
+
Split long how-to collections into task pages. Include code,
|
|
93
|
+
table implications, and visible output in issues and PRs where they help
|
|
94
|
+
the reader evaluate a change. Keep verification tallies in the handoff.
|
|
95
|
+
|
|
96
|
+
[Bookstore tutorial](docs/tutorial.md) · [Guide split #85] ·
|
|
97
|
+
[Contributor writing guide](CONTRIBUTING.md#write-for-somebody-trying-it)
|
|
98
|
+
|
|
99
|
+
[Guide split #85]: https://github.com/RickBarretto/narabi-orm/pull/85
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
Storage and concurrency
|
|
103
|
+
-----------------------
|
|
104
|
+
|
|
105
|
+
### Resolve cancellation before reporting the outcome
|
|
106
|
+
|
|
107
|
+
Wait for the in-flight database operation to settle before completing
|
|
108
|
+
transaction cleanup. When commit succeeds, keep committed model state
|
|
109
|
+
and run commit hooks even if the caller receives cancellation. Rollback
|
|
110
|
+
restores model state before rollback hooks. Dispose of an unusable pooled
|
|
111
|
+
connection. A disconnect during commit can leave the outcome unknown.
|
|
112
|
+
|
|
113
|
+
[Cancellation #81]
|
|
114
|
+
|
|
115
|
+
[Cancellation #81]: https://github.com/RickBarretto/narabi-orm/pull/81
|
|
116
|
+
|
|
117
|
+
### Make SQLite WAL opt-in and check the SQLite runtime
|
|
118
|
+
|
|
119
|
+
Expose WAL, durability, and busy timeouts through database configuration.
|
|
120
|
+
Use `transaction(write=True)` when SQLite needs to acquire its writer lock
|
|
121
|
+
before reading. Default transactions begin deferred.
|
|
122
|
+
|
|
123
|
+
Require a known fixed SQLite runtime for explicit WAL opt-in. The gate
|
|
124
|
+
uses the library version reported by Python and accepts the documented
|
|
125
|
+
upstream backports. Python version numbers alone cannot identify the
|
|
126
|
+
SQLite library in a build. Have `narabi doctor` show both observed and
|
|
127
|
+
configured settings so users can see the actual state.
|
|
128
|
+
|
|
129
|
+
[SQLite production settings #82] · [SQLite WAL reset fix]
|
|
130
|
+
|
|
131
|
+
[SQLite production settings #82]: https://github.com/RickBarretto/narabi-orm/pull/82
|
|
132
|
+
[SQLite WAL reset fix]: https://sqlite.org/wal.html#the_wal_reset_bug
|
|
133
|
+
|
|
134
|
+
### Require a filter for a set-based update
|
|
135
|
+
|
|
136
|
+
`Relation.update()` sends one parameterized statement, returns an affected
|
|
137
|
+
row count, and advances managed `updated_at` where present. Require an
|
|
138
|
+
explicit predicate, even for a deliberate update of every visible row.
|
|
139
|
+
The affected count lets a caller tell whether a conditional write, such
|
|
140
|
+
as claiming a job, succeeded. Use instance writes for per-record
|
|
141
|
+
validation and hooks.
|
|
142
|
+
|
|
143
|
+
[Relation updates #84]
|
|
144
|
+
|
|
145
|
+
[Relation updates #84]: https://github.com/RickBarretto/narabi-orm/pull/84
|
|
146
|
+
|
|
147
|
+
### Keep a synchronous projection in the same transaction as its source
|
|
148
|
+
|
|
149
|
+
In the reporting example, write the order and refresh its stored summary
|
|
150
|
+
in one SQLite transaction. Use a typed record for individual report rows
|
|
151
|
+
and grouped dictionaries for totals. The example writes the source first,
|
|
152
|
+
then computes the summary under SQLite's writer lock. Concurrent
|
|
153
|
+
PostgreSQL writers need per-customer serialization or an atomic summary
|
|
154
|
+
update for this pattern.
|
|
155
|
+
|
|
156
|
+
[Reports guide #85]
|
|
157
|
+
|
|
158
|
+
[Reports guide #85]: https://github.com/RickBarretto/narabi-orm/pull/85
|
|
159
|
+
|
|
160
|
+
### Opt in to stale-write protection per table
|
|
161
|
+
|
|
162
|
+
`@table(optimistic_lock=True)` adds a managed `version` column that starts
|
|
163
|
+
at `1`. Guard instance saves, deletes, and restores with the loaded version.
|
|
164
|
+
Raise `StaleRecordError` on conflict and preserve pending edits for review and
|
|
165
|
+
retry. Set-based updates and bulk upserts advance versions so loaded instances
|
|
166
|
+
become stale. Rollback restores the recorded version.
|
|
167
|
+
|
|
168
|
+
[Optimistic locking #86]
|
|
169
|
+
|
|
170
|
+
[Optimistic locking #86]: https://github.com/RickBarretto/narabi-orm/pull/86
|
|
171
|
+
|
|
172
|
+
### Infer models for adoption against an existing database
|
|
173
|
+
|
|
174
|
+
`narabi schema infer` reads the live catalog and emits Python models for
|
|
175
|
+
usable tables. Keep physical identifiers explicit and apply inflection
|
|
176
|
+
rules to class names, such as `books` becoming `Book`. Keep stdout usable as
|
|
177
|
+
a Python file, report unsupported structures on stderr, and require
|
|
178
|
+
`--force` to replace an output file. The inspected SQLite database and its
|
|
179
|
+
journal files stay protected.
|
|
180
|
+
|
|
181
|
+
Treat the live database as the source of truth while adopting it.
|
|
182
|
+
Inferred models can omit database-only checks, indexes, or defaults.
|
|
183
|
+
Migration baselining is a deliberate separate operation.
|
|
184
|
+
|
|
185
|
+
[Live inference #87]
|
|
186
|
+
|
|
187
|
+
[Live inference #87]: https://github.com/RickBarretto/narabi-orm/pull/87
|
|
188
|
+
|
|
189
|
+
### Preserve enum meaning with a stable lookup ID
|
|
190
|
+
|
|
191
|
+
A stored enum field references a lookup ID. The lookup also records the
|
|
192
|
+
member name and value, so a reordered `IntEnum.auto()` declaration
|
|
193
|
+
that changes a number raises a mismatch. Capture the initial IDs in the
|
|
194
|
+
generated migration. Allow explicit renumbering and swaps while keeping
|
|
195
|
+
IDs stable. Reject duplicate values atomically and reserve retired IDs.
|
|
196
|
+
|
|
197
|
+
When converting a scalar column or switching enum tables, map by meaning.
|
|
198
|
+
The example updates all rows for one lookup value at a time and checks
|
|
199
|
+
for unmapped rows before enforcing the final constraint.
|
|
200
|
+
|
|
201
|
+
[Persistent enums #88]
|
|
202
|
+
|
|
203
|
+
[Persistent enums #88]: https://github.com/RickBarretto/narabi-orm/pull/88
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
Why Narabi exists
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
I wanted a Python ORM I would reach for before writing SQL by hand.
|
|
5
|
+
|
|
6
|
+
With SQLAlchemy, I often found that writing the SQL directly felt easier than
|
|
7
|
+
setting up the objects around it. I had the same experience with migration
|
|
8
|
+
tools such as Alembic andkv Aerich. For the projects I was working on, the
|
|
9
|
+
amount of code between the task and the result was more than I wanted to
|
|
10
|
+
maintain. SQLModel's typed models appealed to me, but when I tried to use them
|
|
11
|
+
asynchronously, the examples I needed were hard to find. These projects make
|
|
12
|
+
different tradeoffs, and many applications benefit from them.
|
|
13
|
+
|
|
14
|
+
Rails Active Record gave me a model for what I wanted. Start with a book. Ask
|
|
15
|
+
the book model for its rows. Save a change through the book you already have.
|
|
16
|
+
Use a transaction when an operation needs one. Narabi brings that workflow to
|
|
17
|
+
ordinary Python classes with type annotations and explicit `await`.
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Make the common path short
|
|
21
|
+
--------------------------
|
|
22
|
+
|
|
23
|
+
A reader looking up a book should be able to follow the query without first
|
|
24
|
+
learning how the application assembled its persistence layer. A developer
|
|
25
|
+
reviewing a schema change should be able to read the generated migration,
|
|
26
|
+
inspect the SQL, and see which changes require extra care. Narabi puts those
|
|
27
|
+
operations in the same library so there is one workflow to learn.
|
|
28
|
+
|
|
29
|
+
Short code is valuable when each line does something you can name. Narabi uses
|
|
30
|
+
conventions for choices such as table naming when a project opts in. It keeps
|
|
31
|
+
transaction boundaries and schema changes visible. When SQL expresses an idea
|
|
32
|
+
more directly, use `Database.execute()` with bound parameters.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
Make sensitive fields visible in the model
|
|
36
|
+
------------------------------------------
|
|
37
|
+
|
|
38
|
+
The maintainer reading a customer model should be able to see which fields are
|
|
39
|
+
personal, sensitive, or private. Narabi uses that classification to redact
|
|
40
|
+
record representations, omit private fields from default serialization, and
|
|
41
|
+
show an inventory of classified fields. The declaration sits beside the field
|
|
42
|
+
it describes, where someone reviewing a change can see it.
|
|
43
|
+
|
|
44
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
45
|
+
|
|
46
|
+
Start with the [bookstore tutorial](docs/tutorial.md) or see
|
|
47
|
+
[how the same workflow looks in other libraries](docs/comparisons.md).
|