kakaorm 0.3.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.
@@ -0,0 +1,92 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ name: Test (Python ${{ matrix.python-version }})
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ python-version: ["3.11", "3.12", "3.13"]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ pip install -e ".[aiosqlite,dev]"
29
+
30
+ - name: Lint (ruff)
31
+ run: ruff check kakaorm/
32
+
33
+ - name: Run tests
34
+ run: pytest --tb=short -q
35
+
36
+ test-mysql:
37
+ name: Test MySQL
38
+ runs-on: ubuntu-latest
39
+
40
+ services:
41
+ mysql:
42
+ image: mysql:8.0
43
+ env:
44
+ MYSQL_ROOT_PASSWORD: root
45
+ MYSQL_DATABASE: test_db
46
+ ports:
47
+ - 3306:3306
48
+ options: >-
49
+ --health-cmd="mysqladmin ping -h 127.0.0.1 --silent"
50
+ --health-interval=10s
51
+ --health-timeout=5s
52
+ --health-retries=5
53
+
54
+ steps:
55
+ - uses: actions/checkout@v4
56
+
57
+ - name: Set up Python
58
+ uses: actions/setup-python@v5
59
+ with:
60
+ python-version: "3.12"
61
+
62
+ - name: Install dependencies
63
+ run: pip install -e ".[aiomysql,dev]" cryptography
64
+
65
+ - name: Run MySQL tests
66
+ env:
67
+ KAKAORM_MYSQL_URL: mysql+aiomysql://root:root@127.0.0.1:3306/test_db
68
+ run: pytest tests/test_mysql.py --tb=short -v
69
+
70
+ build:
71
+ name: Build distribution
72
+ runs-on: ubuntu-latest
73
+ needs: test
74
+
75
+ steps:
76
+ - uses: actions/checkout@v4
77
+
78
+ - name: Set up Python
79
+ uses: actions/setup-python@v5
80
+ with:
81
+ python-version: "3.12"
82
+
83
+ - name: Build
84
+ run: |
85
+ pip install build
86
+ python -m build
87
+
88
+ - name: Upload dist
89
+ uses: actions/upload-artifact@v4
90
+ with:
91
+ name: dist
92
+ path: dist/
@@ -0,0 +1,69 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ *.egg
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+ eggs/
11
+ parts/
12
+ var/
13
+ sdist/
14
+ wheels/
15
+ *.egg-link
16
+ MANIFEST
17
+
18
+ # Virtual environments
19
+ .venv/
20
+ venv/
21
+ env/
22
+ ENV/
23
+
24
+ # Testing
25
+ .pytest_cache/
26
+ .coverage
27
+ htmlcov/
28
+ .tox/
29
+ .nox/
30
+
31
+ # Type checking
32
+ .mypy_cache/
33
+ .pytype/
34
+ .pyre/
35
+
36
+ # IDE
37
+ .idea/
38
+ .vscode/
39
+ *.swp
40
+ *.swo
41
+ *~
42
+
43
+ # OS
44
+ .DS_Store
45
+ Thumbs.db
46
+
47
+ # Distribution / packaging
48
+ pip-wheel-metadata/
49
+ share/python-wheels/
50
+
51
+ # Jupyter
52
+ .ipynb_checkpoints/
53
+
54
+ # Environment variables
55
+ .env
56
+ .env.*
57
+ !.env.example
58
+
59
+ # Logs
60
+ *.log
61
+ logs/
62
+
63
+ # Database files
64
+ *.db
65
+ *.sqlite
66
+ *.sqlite3
67
+
68
+ # Build artifacts
69
+ *.spec
@@ -0,0 +1,104 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.3.0] - 2026-06-01
9
+
10
+ ### Added
11
+
12
+ - **SoftDeleteModel** — Logical deletion base class:
13
+ - `delete()` sets `deleted_at` instead of physically removing the record
14
+ - `deleted_at` column is added automatically
15
+ - Default queries exclude soft-deleted records (`deleted_at IS NULL`)
16
+ - `include_deleted()` — include soft-deleted records in queries
17
+ - `only_deleted()` — query only soft-deleted records
18
+ - `restore()` — cancel logical deletion (instance and QuerySet level)
19
+ - `purge()` — physically delete soft-deleted records
20
+ - `count()`, `update()`, `aggregate()` respect the deletion filter automatically
21
+ - **ArchiveModel** — Archive deletion base class:
22
+ - `delete()` moves the record to `archive_{table}` within a transaction (INSERT + DELETE)
23
+ - Archive table is created separately via `engine.create_archive_table(Model)`
24
+ - Default queries target the main table only
25
+ - `include_deleted()` — UNION ALL across main and archive tables
26
+ - `only_deleted()` — query the archive table only
27
+ - `restore()` — move record back from archive to main table (instance and QuerySet level)
28
+ - `purge()` — physically delete from the archive table
29
+ - **`engine.create_archive_table()`** — Creates `archive_{table}` with the same schema as the main table plus an `archived_at` timestamp column
30
+ - **autogenerate archive support** — `autogenerate()` now detects `ArchiveModel` subclasses and includes the archive table in the diff plan automatically
31
+
32
+ ### Changed
33
+
34
+ - `Migrator.plan()` expands `ArchiveModel` subclasses to also plan their corresponding archive tables
35
+
36
+ [0.3.0]: https://github.com/AyumuTakai/KakaORM/releases/tag/v0.3.0
37
+
38
+ ## [0.2.0] - 2026-06-01
39
+
40
+ ### Added
41
+
42
+ - **CTE (WITH clause)** — Complex query support via `with_cte()` method
43
+ - **Eager loading (prefetch)** — N+1 problem elimination with `prefetch()` method for all relationship types
44
+ - **Migration downgrade** — Rollback capability via `downgrade()` method with automatic reverse SQL generation
45
+ - **Migration autogenerate** — Automatic migration file generation via `autogenerate()` from model-DB diffs
46
+ - **Migration CLI** — Command-line interface via `kakaorm` command:
47
+ - `kakaorm init` — Initialize migrations directory
48
+ - `kakaorm makemigrations` — Auto-generate migration files
49
+ - `kakaorm migrate` — Apply or rollback migrations
50
+ - `kakaorm showmigrations` — View migration history
51
+ - **Window Functions** — SQL window functions support:
52
+ - `RowNumber()`, `Rank()`, `DenseRank()` for ranking
53
+ - `Lag()`, `Lead()` for offset functions
54
+ - `Sum().over()`, `Avg().over()`, `Min().over()`, `Max().over()` for aggregate windows
55
+ - **FastAPI Integration Guide** — Comprehensive documentation with 3 example implementations:
56
+ - `fastapi_advanced.py` — Dependency injection and multi-model patterns
57
+ - `fastapi_pagination.py` — Pagination and filtering
58
+ - `fastapi_testing.py` — Testing strategies
59
+
60
+ ### Changed
61
+
62
+ - Enhanced `QuerySet._parse_exprs()` to recognize and handle window functions
63
+ - Extended `AggFunc` with `.over()` method for aggregate window support
64
+ - Improved `Pydantic v2` integration documentation
65
+
66
+ ### Fixed
67
+
68
+ - None reported
69
+
70
+ [0.2.0]: https://github.com/AyumuTakai/KakaORM/releases/tag/v0.2.0
71
+
72
+ ## [0.1.0] - 2026-06-01
73
+
74
+ ### Added
75
+
76
+ - `Model` base class with `AsyncORMMeta` metaclass for declarative model definitions
77
+ - Column types: `IntColumn`, `StrColumn`, `FloatColumn`, `BoolColumn`, `DateTimeColumn`, `DateColumn`, `TimeColumn`, `DecimalColumn`, `ForeignKey`
78
+ - User-defined primary keys (`primary_key=True` on any column)
79
+ - `QuerySet` lazy query builder with chainable API: `where()`, `order_by()`, `limit()`, `offset()`, `select()`, `group_by()`, `having()`
80
+ - WHERE operators: `==`, `!=`, `>=`, `>`, `<=`, `<`, `IS NULL`, `LIKE`, `ILIKE`, `IN`, `NOT IN`, `BETWEEN`
81
+ - Boolean operators: `&` (AND), `|` (OR), `~` (NOT)
82
+ - Aggregate functions: `Count`, `Sum`, `Avg`, `Max`, `Min`
83
+ - `CASE WHEN` expression support in SELECT and UPDATE
84
+ - JOIN support: `join()` (INNER), `left_join()` (LEFT OUTER)
85
+ - Subquery support: `WHERE col IN (SELECT ...)` via `Subquery`
86
+ - Bulk operations: `bulk_create()`, `QuerySet.update()`, `QuerySet.delete()`, `truncate()`
87
+ - `INSERT ... SELECT` via `QuerySet.insert_into()`
88
+ - UPDATE column-reference expressions: `Post.all().update(views=Post.views + 1)`
89
+ - Event hooks: `before_insert`, `after_insert`, `before_update`, `after_update`, `before_delete`, `after_delete`
90
+ - Relationship descriptors: `has_many()`, `has_one()`, `belongs_to()`
91
+ - Composite indexes via `Meta.indexes`
92
+ - CHECK constraints via `check=` column option
93
+ - Explicit transaction support via `engine.transaction()` context manager
94
+ - Raw SQL access: `engine.fetch()`, `engine.execute()`, `engine.fetchval()`
95
+ - `Migrator` — diff-based schema migration (ADD COLUMN, DROP COLUMN, ADD CONSTRAINT)
96
+ - `VersionedMigrator` — migration history tracked in `kakaorm_migrations` table
97
+ - `DROP TABLE CASCADE` support
98
+ - Pydantic v2 protocol: `model_dump()`, `model_validate()`, `__get_pydantic_core_schema__()`, `__get_pydantic_json_schema__()` — enables direct use as FastAPI `response_model`
99
+ - Engine backends: `AsyncpgEngine` (PostgreSQL/asyncpg), `Psycopg3Engine` (PostgreSQL/psycopg3), `AioSQLiteEngine` (SQLite/aiosqlite), `AioMySQLEngine` (MySQL-MariaDB/aiomysql)
100
+ - `connect()` factory function with URL-based engine selection
101
+ - Security: column-name whitelist validation on `update()` and `insert_into()`
102
+ - `py.typed` marker for PEP 561 compliance
103
+
104
+ [0.1.0]: https://github.com/AyumuTakai/KakaORM/releases/tag/v0.1.0
kakaorm-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ayumu Takai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.