Skip to content

Commit b574e55

Browse files
authored
fix: add URL signing methods to ObjectStoreProtocol and storage backends (#287)
Adds proper URL signing support to storage backends with type-safe methods in the `ObjectStoreProtocol`. Also includes logging improvements across the codebase and a new config normalization utility.
1 parent 7fe8f6c commit b574e55

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1914
-500
lines changed

AGENTS.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,53 @@ class AdapterConfig(AsyncDatabaseConfig): # or SyncDatabaseConfig
510510

511511
- v0.33.0+: `pool_config``connection_config`, `pool_instance``connection_instance`
512512

513+
### Parameter Deprecation Pattern
514+
515+
For backwards-compatible parameter renames in configuration classes:
516+
517+
```python
518+
def __init__(
519+
self,
520+
*,
521+
new_param: dict[str, Any] | None = None,
522+
**kwargs: Any, # Capture old parameter names
523+
) -> None:
524+
from sqlspec.utils.deprecation import warn_deprecation
525+
526+
if "old_param" in kwargs:
527+
warn_deprecation(
528+
version="0.33.0",
529+
deprecated_name="old_param",
530+
kind="parameter",
531+
removal_in="0.34.0",
532+
alternative="new_param",
533+
info="Parameter renamed for consistency across pooled and non-pooled adapters",
534+
)
535+
if new_param is None:
536+
new_param = kwargs.pop("old_param")
537+
else:
538+
kwargs.pop("old_param") # Discard if new param provided
539+
540+
# Continue with initialization using new_param
541+
```
542+
543+
**Use this pattern when:**
544+
545+
- Renaming configuration parameters for consistency
546+
- Need backwards compatibility during migration period
547+
- Want clear deprecation warnings for users
548+
549+
**Key principles:**
550+
551+
- Use `**kwargs` to capture old parameter names without changing signature
552+
- Import `warn_deprecation` inside function to avoid circular imports
553+
- New parameter takes precedence when both old and new provided
554+
- Use `kwargs.pop()` to remove handled parameters and avoid `**kwargs` passing issues
555+
- Provide clear migration path (version, alternative, removal timeline)
556+
- Set removal timeline (typically next minor or major version)
557+
558+
**Reference implementation:** `sqlspec/config.py` (lines 920-1517, all 4 base config classes)
559+
513560
### Error Handling
514561

515562
- Custom exceptions inherit from `SQLSpecError` in `sqlspec/exceptions.py`

docs/migration-guides/v0.33.0.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Migration Guide: v0.33.0
2+
3+
## Configuration Parameter Renaming
4+
5+
SQLSpec v0.33.0 renames configuration parameters for consistency across all database adapters.
6+
7+
### Changed Parameters
8+
9+
| Old Name | New Name | Affected Configs |
10+
|----------|----------|------------------|
11+
| `pool_config` | `connection_config` | All adapters |
12+
| `pool_instance` | `connection_instance` | All adapters |
13+
14+
### Migration Steps
15+
16+
Update your configuration instantiation to use the new parameter names:
17+
18+
```python
19+
# Before (deprecated, will be removed in v0.34.0)
20+
from sqlspec.adapters.asyncpg import AsyncpgConfig
21+
22+
config = AsyncpgConfig(
23+
pool_config={"dsn": "postgresql://localhost/mydb"},
24+
pool_instance=existing_pool,
25+
)
26+
```
27+
28+
```python
29+
# After (recommended)
30+
from sqlspec.adapters.asyncpg import AsyncpgConfig
31+
32+
config = AsyncpgConfig(
33+
connection_config={"dsn": "postgresql://localhost/mydb"},
34+
connection_instance=existing_pool,
35+
)
36+
```
37+
38+
### Rationale
39+
40+
The new parameter names accurately reflect usage across both:
41+
42+
- **Pooled adapters** (AsyncPG, DuckDB, Psycopg, etc.) - where the parameters configure connection pools
43+
- **Non-pooled adapters** (BigQuery, ADBC, Spanner) - where the parameters configure individual connections
44+
45+
This eliminates conceptual confusion and provides consistent API across all adapters.
46+
47+
### Backwards Compatibility
48+
49+
**Deprecation Period**: v0.33.0 - v0.33.x
50+
51+
Old parameter names continue to work with deprecation warnings. You will see warnings like:
52+
53+
```
54+
DeprecationWarning: Use of deprecated parameter 'pool_config'.
55+
Deprecated in SQLSpec 0.33.0.
56+
This parameter will be removed in 0.34.0.
57+
Use 'connection_config' instead.
58+
Parameter renamed for consistency across pooled and non-pooled adapters.
59+
```
60+
61+
**Breaking Change**: v0.34.0
62+
63+
Old parameter names will be completely removed in v0.34.0. Update your code during the deprecation period to avoid breakage.
64+
65+
### Affected Adapters
66+
67+
All database adapter configurations are affected:
68+
69+
- **Async Pooled**: AsyncPG, Asyncmy, Aiosqlite, Psqlpy, Psycopg (async), Spanner (async), Oracle (async)
70+
- **Sync Pooled**: DuckDB, SQLite, Psycopg (sync), Spanner (sync), Oracle (sync)
71+
- **Non-pooled**: BigQuery, ADBC
72+
73+
### Type Checking
74+
75+
Type checkers (mypy, pyright) will not autocomplete or recognize the old parameter names. This is intentional to encourage migration to the new names.
76+
77+
### Examples
78+
79+
#### AsyncPG (Pooled)
80+
81+
```python
82+
from sqlspec.adapters.asyncpg import AsyncpgConfig
83+
84+
# Old
85+
config = AsyncpgConfig(
86+
pool_config={"dsn": "postgresql://localhost/db", "min_size": 5, "max_size": 10}
87+
)
88+
89+
# New
90+
config = AsyncpgConfig(
91+
connection_config={"dsn": "postgresql://localhost/db", "min_size": 5, "max_size": 10}
92+
)
93+
```
94+
95+
#### BigQuery (Non-pooled)
96+
97+
```python
98+
from sqlspec.adapters.bigquery import BigQueryConfig
99+
100+
# Old
101+
config = BigQueryConfig(
102+
pool_config={"project": "my-project"}
103+
)
104+
105+
# New
106+
config = BigQueryConfig(
107+
connection_config={"project": "my-project"}
108+
)
109+
```
110+
111+
#### Pre-created Pool Instance
112+
113+
```python
114+
import asyncpg
115+
from sqlspec.adapters.asyncpg import AsyncpgConfig
116+
117+
pool = await asyncpg.create_pool(dsn="postgresql://localhost/db")
118+
119+
# Old
120+
config = AsyncpgConfig(pool_instance=pool)
121+
122+
# New
123+
config = AsyncpgConfig(connection_instance=pool)
124+
```
125+
126+
### Search and Replace
127+
128+
For quick migration across your codebase:
129+
130+
```bash
131+
# Find all occurrences
132+
grep -r "pool_config" . --include="*.py"
133+
grep -r "pool_instance" . --include="*.py"
134+
135+
# Replace (GNU sed)
136+
find . -name "*.py" -exec sed -i 's/pool_config=/connection_config=/g' {} +
137+
find . -name "*.py" -exec sed -i 's/pool_instance=/connection_instance=/g' {} +
138+
```
139+
140+
Review changes carefully after automated replacement to ensure correctness.
141+
142+
## Questions?
143+
144+
If you encounter issues during migration:
145+
146+
1. Check that you're using SQLSpec v0.33.0 or later
147+
2. Verify deprecation warnings appear (ensures old names are recognized)
148+
3. Update to new parameter names when you see warnings
149+
4. Test your application thoroughly after migration
150+
151+
Report migration issues at: https://github.com/litestar-org/sqlspec/issues

0 commit comments

Comments
 (0)