rowquery 0.1.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.
- rowquery-0.1.0/.github/ISSUE_TEMPLATE/bug_report.yml +71 -0
- rowquery-0.1.0/.github/ISSUE_TEMPLATE/config.yml +5 -0
- rowquery-0.1.0/.github/ISSUE_TEMPLATE/feature_request.yml +38 -0
- rowquery-0.1.0/.github/PULL_REQUEST_TEMPLATE.md +42 -0
- rowquery-0.1.0/.github/dependabot.yml +31 -0
- rowquery-0.1.0/.github/workflows/quality.yml +75 -0
- rowquery-0.1.0/.github/workflows/release.yml +99 -0
- rowquery-0.1.0/.github/workflows/test.yml +48 -0
- rowquery-0.1.0/.gitignore +29 -0
- rowquery-0.1.0/.pre-commit-config.yaml +18 -0
- rowquery-0.1.0/CHANGELOG.md +44 -0
- rowquery-0.1.0/CLAUDE.md +68 -0
- rowquery-0.1.0/CODE_OF_CONDUCT.md +83 -0
- rowquery-0.1.0/CONTRIBUTING.md +216 -0
- rowquery-0.1.0/LICENSE +21 -0
- rowquery-0.1.0/PKG-INFO +252 -0
- rowquery-0.1.0/README.md +203 -0
- rowquery-0.1.0/examples/01_basic_query.py +78 -0
- rowquery-0.1.0/examples/02_model_mapping.py +93 -0
- rowquery-0.1.0/examples/03_aggregate.py +119 -0
- rowquery-0.1.0/examples/04_transactions.py +100 -0
- rowquery-0.1.0/examples/05_async.py +107 -0
- rowquery-0.1.0/examples/06_migrations.py +96 -0
- rowquery-0.1.0/examples/07_repository.py +168 -0
- rowquery-0.1.0/examples/README.md +92 -0
- rowquery-0.1.0/pyproject.toml +109 -0
- rowquery-0.1.0/row_query/__init__.py +83 -0
- rowquery-0.1.0/row_query/adapters/__init__.py +0 -0
- rowquery-0.1.0/row_query/adapters/mysql.py +111 -0
- rowquery-0.1.0/row_query/adapters/oracle.py +120 -0
- rowquery-0.1.0/row_query/adapters/postgresql.py +104 -0
- rowquery-0.1.0/row_query/adapters/protocol.py +81 -0
- rowquery-0.1.0/row_query/adapters/sqlite.py +98 -0
- rowquery-0.1.0/row_query/core/__init__.py +0 -0
- rowquery-0.1.0/row_query/core/connection.py +132 -0
- rowquery-0.1.0/row_query/core/engine.py +419 -0
- rowquery-0.1.0/row_query/core/enums.py +14 -0
- rowquery-0.1.0/row_query/core/exceptions.py +145 -0
- rowquery-0.1.0/row_query/core/migration.py +148 -0
- rowquery-0.1.0/row_query/core/params.py +122 -0
- rowquery-0.1.0/row_query/core/registry.py +95 -0
- rowquery-0.1.0/row_query/core/sanitizer.py +233 -0
- rowquery-0.1.0/row_query/core/transaction.py +334 -0
- rowquery-0.1.0/row_query/mapping/__init__.py +26 -0
- rowquery-0.1.0/row_query/mapping/aggregate.py +175 -0
- rowquery-0.1.0/row_query/mapping/builder.py +224 -0
- rowquery-0.1.0/row_query/mapping/model.py +85 -0
- rowquery-0.1.0/row_query/mapping/plan.py +57 -0
- rowquery-0.1.0/row_query/mapping/protocol.py +23 -0
- rowquery-0.1.0/row_query/repository/__init__.py +10 -0
- rowquery-0.1.0/row_query/repository/base.py +56 -0
- rowquery-0.1.0/tests/__init__.py +0 -0
- rowquery-0.1.0/tests/conftest.py +38 -0
- rowquery-0.1.0/tests/contract/__init__.py +0 -0
- rowquery-0.1.0/tests/contract/test_adapter_protocol.py +163 -0
- rowquery-0.1.0/tests/fixtures/sql/billing/invoice/list.sql +3 -0
- rowquery-0.1.0/tests/fixtures/sql/user/count.sql +1 -0
- rowquery-0.1.0/tests/fixtures/sql/user/get_by_id.sql +3 -0
- rowquery-0.1.0/tests/fixtures/sql/user/insert.sql +2 -0
- rowquery-0.1.0/tests/fixtures/sql/user/list.sql +3 -0
- rowquery-0.1.0/tests/integration/__init__.py +0 -0
- rowquery-0.1.0/tests/integration/test_sqlite.py +335 -0
- rowquery-0.1.0/tests/unit/__init__.py +0 -0
- rowquery-0.1.0/tests/unit/test_aggregate_mapper.py +333 -0
- rowquery-0.1.0/tests/unit/test_builder.py +174 -0
- rowquery-0.1.0/tests/unit/test_engine.py +77 -0
- rowquery-0.1.0/tests/unit/test_migration.py +138 -0
- rowquery-0.1.0/tests/unit/test_model_mapper.py +88 -0
- rowquery-0.1.0/tests/unit/test_params.py +51 -0
- rowquery-0.1.0/tests/unit/test_registry.py +94 -0
- rowquery-0.1.0/tests/unit/test_repository.py +69 -0
- rowquery-0.1.0/tests/unit/test_sanitizer.py +345 -0
- rowquery-0.1.0/tests/unit/test_transaction.py +90 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: File a bug report
|
|
3
|
+
title: "[Bug]: "
|
|
4
|
+
labels: ["bug", "triage"]
|
|
5
|
+
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: Thanks for taking the time to file a bug report!
|
|
10
|
+
|
|
11
|
+
- type: textarea
|
|
12
|
+
id: description
|
|
13
|
+
attributes:
|
|
14
|
+
label: Describe the bug
|
|
15
|
+
description: A clear description of what the bug is
|
|
16
|
+
validations:
|
|
17
|
+
required: true
|
|
18
|
+
|
|
19
|
+
- type: textarea
|
|
20
|
+
id: reproduction
|
|
21
|
+
attributes:
|
|
22
|
+
label: Reproduction steps
|
|
23
|
+
description: Steps to reproduce the behavior
|
|
24
|
+
placeholder: |
|
|
25
|
+
1. Create engine with...
|
|
26
|
+
2. Execute query...
|
|
27
|
+
3. See error
|
|
28
|
+
validations:
|
|
29
|
+
required: true
|
|
30
|
+
|
|
31
|
+
- type: textarea
|
|
32
|
+
id: expected
|
|
33
|
+
attributes:
|
|
34
|
+
label: Expected behavior
|
|
35
|
+
description: What you expected to happen
|
|
36
|
+
validations:
|
|
37
|
+
required: true
|
|
38
|
+
|
|
39
|
+
- type: input
|
|
40
|
+
id: version
|
|
41
|
+
attributes:
|
|
42
|
+
label: RowQuery Version
|
|
43
|
+
placeholder: "0.1.0"
|
|
44
|
+
validations:
|
|
45
|
+
required: true
|
|
46
|
+
|
|
47
|
+
- type: input
|
|
48
|
+
id: python-version
|
|
49
|
+
attributes:
|
|
50
|
+
label: Python Version
|
|
51
|
+
placeholder: "3.12"
|
|
52
|
+
validations:
|
|
53
|
+
required: true
|
|
54
|
+
|
|
55
|
+
- type: dropdown
|
|
56
|
+
id: database
|
|
57
|
+
attributes:
|
|
58
|
+
label: Database Backend
|
|
59
|
+
options:
|
|
60
|
+
- SQLite
|
|
61
|
+
- PostgreSQL
|
|
62
|
+
- MySQL
|
|
63
|
+
- Oracle
|
|
64
|
+
validations:
|
|
65
|
+
required: true
|
|
66
|
+
|
|
67
|
+
- type: textarea
|
|
68
|
+
id: additional
|
|
69
|
+
attributes:
|
|
70
|
+
label: Additional context
|
|
71
|
+
description: Any other context about the problem
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Suggest a new feature
|
|
3
|
+
title: "[Feature]: "
|
|
4
|
+
labels: ["enhancement"]
|
|
5
|
+
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: Thanks for suggesting a new feature!
|
|
10
|
+
|
|
11
|
+
- type: textarea
|
|
12
|
+
id: problem
|
|
13
|
+
attributes:
|
|
14
|
+
label: Problem Description
|
|
15
|
+
description: What problem does this feature solve?
|
|
16
|
+
placeholder: I'm always frustrated when...
|
|
17
|
+
validations:
|
|
18
|
+
required: true
|
|
19
|
+
|
|
20
|
+
- type: textarea
|
|
21
|
+
id: solution
|
|
22
|
+
attributes:
|
|
23
|
+
label: Proposed Solution
|
|
24
|
+
description: How would you like to see this implemented?
|
|
25
|
+
validations:
|
|
26
|
+
required: true
|
|
27
|
+
|
|
28
|
+
- type: textarea
|
|
29
|
+
id: alternatives
|
|
30
|
+
attributes:
|
|
31
|
+
label: Alternatives Considered
|
|
32
|
+
description: Any alternative solutions or workarounds?
|
|
33
|
+
|
|
34
|
+
- type: textarea
|
|
35
|
+
id: additional
|
|
36
|
+
attributes:
|
|
37
|
+
label: Additional Context
|
|
38
|
+
description: Any other context or examples
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
## Description
|
|
2
|
+
|
|
3
|
+
<!-- Describe your changes in detail -->
|
|
4
|
+
|
|
5
|
+
## Type of Change
|
|
6
|
+
|
|
7
|
+
- [ ] Bug fix (non-breaking change which fixes an issue)
|
|
8
|
+
- [ ] New feature (non-breaking change which adds functionality)
|
|
9
|
+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
|
10
|
+
- [ ] Documentation update
|
|
11
|
+
- [ ] Refactoring (no functional changes)
|
|
12
|
+
- [ ] Performance improvement
|
|
13
|
+
- [ ] Test addition or update
|
|
14
|
+
|
|
15
|
+
## Related Issues
|
|
16
|
+
|
|
17
|
+
<!-- Link to related issues: Fixes #123, Closes #456 -->
|
|
18
|
+
|
|
19
|
+
## Checklist
|
|
20
|
+
|
|
21
|
+
- [ ] My code follows the style guidelines (ruff, mypy)
|
|
22
|
+
- [ ] I have added tests that prove my fix/feature works
|
|
23
|
+
- [ ] All tests pass locally (`uv run pytest`)
|
|
24
|
+
- [ ] I have updated the documentation (if needed)
|
|
25
|
+
- [ ] I have updated CHANGELOG.md (if needed)
|
|
26
|
+
- [ ] Pre-commit hooks pass
|
|
27
|
+
|
|
28
|
+
## Testing
|
|
29
|
+
|
|
30
|
+
<!-- Describe how you tested your changes -->
|
|
31
|
+
|
|
32
|
+
- [ ] Unit tests added/updated
|
|
33
|
+
- [ ] Integration tests added/updated
|
|
34
|
+
- [ ] Manual testing performed
|
|
35
|
+
|
|
36
|
+
## Screenshots/Examples
|
|
37
|
+
|
|
38
|
+
<!-- If applicable, add screenshots or code examples -->
|
|
39
|
+
|
|
40
|
+
## Additional Notes
|
|
41
|
+
|
|
42
|
+
<!-- Any other information about this PR -->
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
# Python dependencies
|
|
4
|
+
- package-ecosystem: "pip"
|
|
5
|
+
directory: "/"
|
|
6
|
+
schedule:
|
|
7
|
+
interval: "weekly"
|
|
8
|
+
day: "monday"
|
|
9
|
+
open-pull-requests-limit: 5
|
|
10
|
+
groups:
|
|
11
|
+
dev-dependencies:
|
|
12
|
+
patterns:
|
|
13
|
+
- "pytest*"
|
|
14
|
+
- "ruff"
|
|
15
|
+
- "mypy"
|
|
16
|
+
- "pre-commit"
|
|
17
|
+
database-drivers:
|
|
18
|
+
patterns:
|
|
19
|
+
- "psycopg*"
|
|
20
|
+
- "aiosqlite"
|
|
21
|
+
- "aiomysql"
|
|
22
|
+
- "mysql-connector-python"
|
|
23
|
+
- "oracledb"
|
|
24
|
+
|
|
25
|
+
# GitHub Actions
|
|
26
|
+
- package-ecosystem: "github-actions"
|
|
27
|
+
directory: "/"
|
|
28
|
+
schedule:
|
|
29
|
+
interval: "weekly"
|
|
30
|
+
day: "monday"
|
|
31
|
+
open-pull-requests-limit: 3
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
name: Quality
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, "001-*"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
lint:
|
|
12
|
+
name: Lint
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v6
|
|
16
|
+
|
|
17
|
+
- name: Install uv
|
|
18
|
+
uses: astral-sh/setup-uv@v5
|
|
19
|
+
with:
|
|
20
|
+
enable-cache: true
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v6
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.12"
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --extra dev
|
|
29
|
+
|
|
30
|
+
- name: Run ruff check
|
|
31
|
+
run: uv run ruff check row_query/ tests/
|
|
32
|
+
|
|
33
|
+
format:
|
|
34
|
+
name: Format Check
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v6
|
|
38
|
+
|
|
39
|
+
- name: Install uv
|
|
40
|
+
uses: astral-sh/setup-uv@v5
|
|
41
|
+
with:
|
|
42
|
+
enable-cache: true
|
|
43
|
+
|
|
44
|
+
- name: Set up Python
|
|
45
|
+
uses: actions/setup-python@v6
|
|
46
|
+
with:
|
|
47
|
+
python-version: "3.12"
|
|
48
|
+
|
|
49
|
+
- name: Install dependencies
|
|
50
|
+
run: uv sync --extra dev
|
|
51
|
+
|
|
52
|
+
- name: Run ruff format check
|
|
53
|
+
run: uv run ruff format --check row_query/ tests/
|
|
54
|
+
|
|
55
|
+
typecheck:
|
|
56
|
+
name: Type Check
|
|
57
|
+
runs-on: ubuntu-latest
|
|
58
|
+
steps:
|
|
59
|
+
- uses: actions/checkout@v6
|
|
60
|
+
|
|
61
|
+
- name: Install uv
|
|
62
|
+
uses: astral-sh/setup-uv@v5
|
|
63
|
+
with:
|
|
64
|
+
enable-cache: true
|
|
65
|
+
|
|
66
|
+
- name: Set up Python
|
|
67
|
+
uses: actions/setup-python@v6
|
|
68
|
+
with:
|
|
69
|
+
python-version: "3.12"
|
|
70
|
+
|
|
71
|
+
- name: Install dependencies
|
|
72
|
+
run: uv sync --extra dev
|
|
73
|
+
|
|
74
|
+
- name: Run mypy
|
|
75
|
+
run: uv run mypy row_query/
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*.*.*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
build:
|
|
14
|
+
name: Build distribution
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v6
|
|
19
|
+
|
|
20
|
+
- name: Install uv
|
|
21
|
+
uses: astral-sh/setup-uv@v5
|
|
22
|
+
|
|
23
|
+
- name: Build package
|
|
24
|
+
run: uv build
|
|
25
|
+
|
|
26
|
+
- name: Store distribution packages
|
|
27
|
+
uses: actions/upload-artifact@v6
|
|
28
|
+
with:
|
|
29
|
+
name: python-package-distributions
|
|
30
|
+
path: dist/
|
|
31
|
+
|
|
32
|
+
publish-to-pypi:
|
|
33
|
+
name: Publish to PyPI
|
|
34
|
+
needs: [build]
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
|
|
37
|
+
steps:
|
|
38
|
+
- name: Download distributions
|
|
39
|
+
uses: actions/download-artifact@v4
|
|
40
|
+
with:
|
|
41
|
+
name: python-package-distributions
|
|
42
|
+
path: dist/
|
|
43
|
+
|
|
44
|
+
- name: Publish to PyPI
|
|
45
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
46
|
+
with:
|
|
47
|
+
skip-existing: true
|
|
48
|
+
|
|
49
|
+
github-release:
|
|
50
|
+
name: Create GitHub Release
|
|
51
|
+
needs: [build]
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v6
|
|
56
|
+
|
|
57
|
+
- name: Download distributions
|
|
58
|
+
uses: actions/download-artifact@v4
|
|
59
|
+
with:
|
|
60
|
+
name: python-package-distributions
|
|
61
|
+
path: dist/
|
|
62
|
+
|
|
63
|
+
- name: Extract release notes
|
|
64
|
+
id: extract-release-notes
|
|
65
|
+
run: |
|
|
66
|
+
VERSION=${GITHUB_REF#refs/tags/v}
|
|
67
|
+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
|
|
68
|
+
|
|
69
|
+
# Extract release notes from CHANGELOG.md if it exists
|
|
70
|
+
if [ -f CHANGELOG.md ]; then
|
|
71
|
+
# Try to extract notes for this version
|
|
72
|
+
awk "/^## \[$VERSION\]/{flag=1;next}/^## \[/{flag=0}flag" CHANGELOG.md > release_notes.md
|
|
73
|
+
if [ -s release_notes.md ]; then
|
|
74
|
+
echo "Found release notes in CHANGELOG.md"
|
|
75
|
+
else
|
|
76
|
+
echo "Release $VERSION" > release_notes.md
|
|
77
|
+
fi
|
|
78
|
+
else
|
|
79
|
+
echo "Release $VERSION" > release_notes.md
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
- name: Create GitHub Release
|
|
83
|
+
env:
|
|
84
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
85
|
+
TAG: ${{ github.ref_name }}
|
|
86
|
+
VERSION: ${{ steps.extract-release-notes.outputs.VERSION }}
|
|
87
|
+
run: |
|
|
88
|
+
# Check if this is a pre-release (version < 1.0.0 or contains alpha/beta/rc)
|
|
89
|
+
if [[ "$VERSION" == 0.* ]] || [[ "$TAG" =~ (alpha|beta|rc) ]]; then
|
|
90
|
+
PRERELEASE_FLAG="--prerelease"
|
|
91
|
+
else
|
|
92
|
+
PRERELEASE_FLAG=""
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
gh release create "$TAG" \
|
|
96
|
+
--title "RowQuery $VERSION" \
|
|
97
|
+
--notes-file release_notes.md \
|
|
98
|
+
$PRERELEASE_FLAG \
|
|
99
|
+
dist/*
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, "001-*"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
name: Test (Python ${{ matrix.python-version }})
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v6
|
|
21
|
+
|
|
22
|
+
- name: Install uv
|
|
23
|
+
uses: astral-sh/setup-uv@v5
|
|
24
|
+
with:
|
|
25
|
+
enable-cache: true
|
|
26
|
+
|
|
27
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
28
|
+
uses: actions/setup-python@v6
|
|
29
|
+
with:
|
|
30
|
+
python-version: ${{ matrix.python-version }}
|
|
31
|
+
|
|
32
|
+
- name: Install dependencies
|
|
33
|
+
run: uv sync --extra sqlite --extra dev
|
|
34
|
+
|
|
35
|
+
- name: Run unit and contract tests
|
|
36
|
+
run: uv run pytest tests/unit/ tests/contract/ -v --cov=row_query --cov-report=xml --cov-report=term
|
|
37
|
+
|
|
38
|
+
- name: Run integration tests
|
|
39
|
+
run: uv run pytest tests/integration/ -m integration -v
|
|
40
|
+
|
|
41
|
+
- name: Upload coverage to Codecov
|
|
42
|
+
if: matrix.python-version == '3.12'
|
|
43
|
+
uses: codecov/codecov-action@v4
|
|
44
|
+
with:
|
|
45
|
+
file: ./coverage.xml
|
|
46
|
+
flags: unittests
|
|
47
|
+
name: codecov-umbrella
|
|
48
|
+
fail_ci_if_error: false
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
*.pyo
|
|
4
|
+
.mypy_cache/
|
|
5
|
+
.vscode/
|
|
6
|
+
.idea/
|
|
7
|
+
poetry.lock
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
htmlcov/
|
|
11
|
+
*.egg-info/
|
|
12
|
+
.coverage*
|
|
13
|
+
coverage.xml
|
|
14
|
+
site/
|
|
15
|
+
*.db
|
|
16
|
+
.cache/
|
|
17
|
+
.venv*/
|
|
18
|
+
venv/
|
|
19
|
+
.claude/
|
|
20
|
+
.specify/
|
|
21
|
+
specs/
|
|
22
|
+
.pytest_cache/
|
|
23
|
+
.ruff_cache/
|
|
24
|
+
*.tmp
|
|
25
|
+
*.swp
|
|
26
|
+
.DS_Store
|
|
27
|
+
Thumbs.db
|
|
28
|
+
.env*
|
|
29
|
+
uv.lock
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
+
rev: v0.4.8
|
|
4
|
+
hooks:
|
|
5
|
+
- id: ruff
|
|
6
|
+
args: [--fix]
|
|
7
|
+
types_or: [python, pyi]
|
|
8
|
+
- id: ruff-format
|
|
9
|
+
types_or: [python, pyi]
|
|
10
|
+
|
|
11
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
12
|
+
rev: v1.10.0
|
|
13
|
+
hooks:
|
|
14
|
+
- id: mypy
|
|
15
|
+
additional_dependencies: [pydantic>=2.0.0]
|
|
16
|
+
args: [--strict]
|
|
17
|
+
pass_filenames: false
|
|
18
|
+
entry: mypy row_query/
|
|
@@ -0,0 +1,44 @@
|
|
|
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.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Inline SQL support**: All engine and transaction methods (`fetch_one`, `fetch_all`, `fetch_scalar`, `execute`) now accept raw SQL strings in addition to registry keys. A string containing whitespace is treated as inline SQL; a dot-separated identifier like `user.get_by_id` is resolved from the registry.
|
|
12
|
+
- **Flexible parameter binding**: `params` argument now accepts `dict` (named), `tuple`/`list` (positional), or a single scalar value (automatically wrapped in a tuple). Previously only `dict | None` was accepted.
|
|
13
|
+
- **`SQLSanitizer`** — configurable sanitizer applied to inline SQL before execution:
|
|
14
|
+
- `strip_comments` (default `True`): removes `--` line comments and `/* */` block comments while preserving string literals.
|
|
15
|
+
- `block_multiple_statements` (default `True`): rejects SQL containing a statement-terminating `;` followed by additional content (prevents query stacking attacks).
|
|
16
|
+
- `allowed_verbs` (default `None`): restricts the leading SQL keyword to a caller-supplied `frozenset` (e.g. `frozenset({"SELECT"})`). Registry queries are never sanitized.
|
|
17
|
+
- **`SQLSanitizationError`** exception (subclass of `ExecutionError`) raised when a sanitization check fails.
|
|
18
|
+
- **`is_raw_sql()`** and **`coerce_params()`** helpers exported from `row_query.core.params`.
|
|
19
|
+
- 65 new unit tests covering all sanitizer behaviour (`tests/unit/test_sanitizer.py`).
|
|
20
|
+
|
|
21
|
+
## [0.1.0] - 2025-02-16
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- Initial alpha release
|
|
25
|
+
- Core query execution engine (`Engine`, `AsyncEngine`)
|
|
26
|
+
- Connection management with pooling support (`ConnectionManager`, `AsyncConnectionManager`)
|
|
27
|
+
- Multi-database adapter pattern supporting SQLite, PostgreSQL, MySQL, and Oracle
|
|
28
|
+
- SQL registry for loading `.sql` files into dot-separated namespaces (`SQLRegistry`)
|
|
29
|
+
- Parameter normalization supporting `:name` syntax across all database backends
|
|
30
|
+
- Model mapping for dataclasses, Pydantic models, and plain classes (`ModelMapper`)
|
|
31
|
+
- Aggregate mapping for complex object graph reconstruction with single-pass O(n) algorithm
|
|
32
|
+
- Collection mapping for one-to-many relationships in aggregate patterns
|
|
33
|
+
- Value object mapping for embedded entities in aggregates
|
|
34
|
+
- Reference mapping for foreign key relationships
|
|
35
|
+
- Transaction management with context manager support (`TransactionManager`, `AsyncTransactionManager`)
|
|
36
|
+
- Migration management system with version tracking (`MigrationManager`, `MigrationInfo`)
|
|
37
|
+
- Repository pattern base classes for DDD-style code organization (`Repository`, `AsyncRepository`)
|
|
38
|
+
- Comprehensive exception hierarchy with 18 custom exception classes
|
|
39
|
+
- Full type safety with mypy strict mode compliance
|
|
40
|
+
- Support for Python 3.10, 3.11, 3.12, and 3.13
|
|
41
|
+
- 125 unit, contract, and integration tests
|
|
42
|
+
|
|
43
|
+
[Unreleased]: https://github.com/maksim-shevtsov/RowQuery/compare/v0.1.0...HEAD
|
|
44
|
+
[0.1.0]: https://github.com/maksim-shevtsov/RowQuery/releases/tag/v0.1.0
|
rowquery-0.1.0/CLAUDE.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
RowQuery is a Python library (alpha, v0.1.0) — a SQL-first query execution and projection engine for multiple database backends. Uses a driver/adapter pattern to support SQLite, PostgreSQL, MySQL, and Oracle. Requires Python >=3.10.
|
|
8
|
+
|
|
9
|
+
## Package Manager
|
|
10
|
+
|
|
11
|
+
This project uses **uv** (not pip/poetry). All commands should go through uv.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
uv sync # Install core + dev dependencies
|
|
15
|
+
uv sync --extra postgres # Install with PostgreSQL support
|
|
16
|
+
uv sync --extra all # Install all database drivers
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Commands
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv run pytest # Run all tests (125 tests)
|
|
23
|
+
uv run pytest tests/unit/ # Unit tests only
|
|
24
|
+
uv run pytest tests/contract/ # Protocol contract tests
|
|
25
|
+
uv run pytest tests/integration/ # SQLite integration tests
|
|
26
|
+
uv run ruff check row_query/ tests/ # Lint
|
|
27
|
+
uv run ruff format row_query/ tests/ # Format
|
|
28
|
+
uv run mypy row_query/ # Type check (strict mode)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Architecture
|
|
32
|
+
|
|
33
|
+
- **`row_query/core/`** — Core engine
|
|
34
|
+
- `connection.py` — `ConnectionConfig` (Pydantic), `ConnectionManager`, `AsyncConnectionManager`
|
|
35
|
+
- `engine.py` — `Engine` and `AsyncEngine` (fetch_one, fetch_all, fetch_scalar, execute, transaction)
|
|
36
|
+
- `registry.py` — `SQLRegistry` (loads .sql files into dot-separated namespaces)
|
|
37
|
+
- `transaction.py` — `TransactionManager`, `AsyncTransactionManager`
|
|
38
|
+
- `migration.py` — `MigrationManager`, `MigrationInfo`
|
|
39
|
+
- `params.py` — `:name` → `%(name)s` parameter normalizer with cache
|
|
40
|
+
- `enums.py` — `DatabaseBackend` enum
|
|
41
|
+
- `exceptions.py` — Full exception hierarchy (18 classes)
|
|
42
|
+
|
|
43
|
+
- **`row_query/adapters/`** — Database drivers
|
|
44
|
+
- `protocol.py` — `SyncAdapter`, `AsyncAdapter` runtime-checkable protocols
|
|
45
|
+
- `sqlite.py` — SQLite adapter (stdlib sqlite3 + aiosqlite)
|
|
46
|
+
- `postgresql.py` — PostgreSQL adapter (psycopg v3)
|
|
47
|
+
- `mysql.py` — MySQL adapter (mysql-connector-python + aiomysql)
|
|
48
|
+
- `oracle.py` — Oracle adapter (oracledb)
|
|
49
|
+
|
|
50
|
+
- **`row_query/mapping/`** — Result mapping
|
|
51
|
+
- `protocol.py` — `Mapper[T]` protocol
|
|
52
|
+
- `model.py` — `ModelMapper` (dataclass, Pydantic, plain class)
|
|
53
|
+
- `plan.py` — Frozen dataclasses: `EntityPlan`, `CollectionPlan`, `ReferencePlan`, `ValueObjectPlan`, `AggregatePlan`
|
|
54
|
+
- `builder.py` — `aggregate()` DSL entry point and `AggregateMappingBuilder`
|
|
55
|
+
- `aggregate.py` — `AggregateMapper` (single-pass O(n) reconstruction)
|
|
56
|
+
|
|
57
|
+
- **`row_query/repository/`** — DDD pattern
|
|
58
|
+
- `base.py` — `Repository`, `AsyncRepository` base classes
|
|
59
|
+
|
|
60
|
+
## Dependencies
|
|
61
|
+
|
|
62
|
+
- **Core**: pydantic >=2.0.0
|
|
63
|
+
- **Optional**: psycopg[binary] >=3.1.0, aiosqlite >=0.20.0, aiomysql >=0.2.0, mysql-connector-python >=8.0.0, oracledb >=2.0.0
|
|
64
|
+
- **Dev**: pytest, pytest-asyncio, ruff, mypy, pre-commit
|
|
65
|
+
|
|
66
|
+
## Active Technologies
|
|
67
|
+
- Python >=3.10 + pydantic >=2.0.0 (core); psycopg >=3.1.0, aiosqlite, aiomysql, oracledb (optional per-backend)
|
|
68
|
+
- SQLite, PostgreSQL, MySQL, Oracle via adapter pattern
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
8
|
+
|
|
9
|
+
## Our Standards
|
|
10
|
+
|
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
12
|
+
|
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
|
18
|
+
|
|
19
|
+
Examples of unacceptable behavior include:
|
|
20
|
+
|
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
|
|
22
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
23
|
+
* Public or private harassment
|
|
24
|
+
* Publishing others' private information, such as a physical or email address, without their explicit permission
|
|
25
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
26
|
+
|
|
27
|
+
## Enforcement Responsibilities
|
|
28
|
+
|
|
29
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
30
|
+
|
|
31
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
32
|
+
|
|
33
|
+
## Scope
|
|
34
|
+
|
|
35
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
36
|
+
|
|
37
|
+
## Enforcement
|
|
38
|
+
|
|
39
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at maksim.shautsou.dev@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
|
40
|
+
|
|
41
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
42
|
+
|
|
43
|
+
## Enforcement Guidelines
|
|
44
|
+
|
|
45
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
46
|
+
|
|
47
|
+
### 1. Correction
|
|
48
|
+
|
|
49
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
50
|
+
|
|
51
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
52
|
+
|
|
53
|
+
### 2. Warning
|
|
54
|
+
|
|
55
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
56
|
+
|
|
57
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
58
|
+
|
|
59
|
+
### 3. Temporary Ban
|
|
60
|
+
|
|
61
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
62
|
+
|
|
63
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
64
|
+
|
|
65
|
+
### 4. Permanent Ban
|
|
66
|
+
|
|
67
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
68
|
+
|
|
69
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
70
|
+
|
|
71
|
+
## Attribution
|
|
72
|
+
|
|
73
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
74
|
+
|
|
75
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
76
|
+
|
|
77
|
+
For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
|
|
78
|
+
|
|
79
|
+
[homepage]: https://www.contributor-covenant.org
|
|
80
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
81
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
82
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
83
|
+
[translations]: https://www.contributor-covenant.org/translations
|