Skip to content

Commit c193542

Browse files
authored
Merge branch 'main' into prek
2 parents 56bd31b + 4c4d5b4 commit c193542

File tree

12 files changed

+375
-48
lines changed

12 files changed

+375
-48
lines changed

.github/workflows/build-docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ jobs:
6565
pyproject.toml
6666
- name: Install docs extras
6767
run: uv pip install -r requirements-docs.txt
68-
- uses: actions/cache@v4
68+
- uses: actions/cache@v5
6969
with:
7070
key: mkdocs-cards-${{ github.ref }}
7171
path: .cache
7272
- name: Verify README
7373
run: python ./scripts/docs.py verify-readme
7474
- name: Build Docs
7575
run: python ./scripts/docs.py build
76-
- uses: actions/upload-artifact@v5
76+
- uses: actions/upload-artifact@v6
7777
with:
7878
name: docs-site
7979
path: ./site/**

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: |
5050
rm -rf ./site
5151
mkdir ./site
52-
- uses: actions/download-artifact@v6
52+
- uses: actions/download-artifact@v7
5353
with:
5454
path: ./site/
5555
pattern: docs-site

.github/workflows/smokeshow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
requirements**.txt
2727
pyproject.toml
2828
- run: uv pip install -r requirements-github-actions.txt
29-
- uses: actions/download-artifact@v6
29+
- uses: actions/download-artifact@v7
3030
with:
3131
name: coverage-html
3232
path: htmlcov

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ jobs:
8888
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.pydantic-version }}
8989
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
9090
- name: Store coverage files
91-
uses: actions/upload-artifact@v5
91+
uses: actions/upload-artifact@v6
9292
with:
9393
name: coverage-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pydantic-version }}
9494
path: coverage
@@ -112,7 +112,7 @@ jobs:
112112
requirements**.txt
113113
pyproject.toml
114114
- name: Get coverage files
115-
uses: actions/download-artifact@v6
115+
uses: actions/download-artifact@v7
116116
with:
117117
pattern: coverage-*
118118
path: coverage
@@ -123,7 +123,7 @@ jobs:
123123
- run: coverage combine coverage
124124
- run: coverage html --title "Coverage for ${{ github.sha }}"
125125
- name: Store coverage HTML
126-
uses: actions/upload-artifact@v5
126+
uses: actions/upload-artifact@v6
127127
with:
128128
name: coverage-html
129129
path: htmlcov

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ repos:
1212
- id: end-of-file-fixer
1313
- id: trailing-whitespace
1414
- repo: https://github.com/astral-sh/ruff-pre-commit
15-
rev: v0.14.8
15+
rev: v0.14.10
1616
hooks:
1717
- id: ruff
1818
args:

docs/release-notes.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,29 @@
22

33
## Latest Changes
44

5+
### Internal
6+
7+
*[pre-commit.ci] pre-commit autoupdate. PR [#1677](https://github.com/fastapi/sqlmodel/pull/1677) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
8+
* ⬆ Bump actions/download-artifact from 6 to 7. PR [#1676](https://github.com/fastapi/sqlmodel/pull/1676) by [@dependabot[bot]](https://github.com/apps/dependabot).
9+
* ⬆ Bump actions/cache from 4 to 5. PR [#1673](https://github.com/fastapi/sqlmodel/pull/1673) by [@dependabot[bot]](https://github.com/apps/dependabot).
10+
* ⬆ Bump markdown-include-variants from 0.0.5 to 0.0.8. PR [#1674](https://github.com/fastapi/sqlmodel/pull/1674) by [@dependabot[bot]](https://github.com/apps/dependabot).
11+
* ⬆ Bump actions/upload-artifact from 5 to 6. PR [#1675](https://github.com/fastapi/sqlmodel/pull/1675) by [@dependabot[bot]](https://github.com/apps/dependabot).
12+
* ⬆ Bump mypy from 1.18.2 to 1.19.1. PR [#1679](https://github.com/fastapi/sqlmodel/pull/1679) by [@dependabot[bot]](https://github.com/apps/dependabot).
13+
* ⬆ Bump typer from 0.20.0 to 0.20.1. PR [#1685](https://github.com/fastapi/sqlmodel/pull/1685) by [@dependabot[bot]](https://github.com/apps/dependabot).
14+
* ⬆ Bump ruff from 0.14.8 to 0.14.10. PR [#1681](https://github.com/fastapi/sqlmodel/pull/1681) by [@dependabot[bot]](https://github.com/apps/dependabot).
15+
16+
## 0.0.29
17+
18+
### Fixes
19+
20+
* 🐛 Fix `alias` support for Pydantic v2. PR [#1577](https://github.com/fastapi/sqlmodel/pull/1577) by [@ravishan16](https://github.com/ravishan16).
21+
22+
## 0.0.28
23+
24+
### Fixes
25+
26+
* 🐛 Fix `RuntimeError: dictionary changed size during iteration` in `sqlmodel_update()`. PR [#997](https://github.com/fastapi/sqlmodel/pull/997) by [@BartSchuurmans](https://github.com/BartSchuurmans).
27+
528
### Docs
629

730
* 💅 Update CSS to explicitly use emoji font. PR [#1658](https://github.com/fastapi/sqlmodel/pull/1658) by [@tiangolo](https://github.com/tiangolo).

requirements-docs.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ mkdocstrings[python]==0.30.1
1414
griffe-typingdoc==0.3.0
1515
griffe-warnings-deprecated==1.1.0
1616
# For griffe, it formats with black
17-
typer == 0.20.0
17+
typer == 0.20.1
1818
mkdocs-macros-plugin==1.5.0
19-
markdown-include-variants==0.0.5
19+
markdown-include-variants==0.0.8

requirements-tests.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ pytest >=7.0.1,<9.0.0
44
coverage[toml] >=6.2,<8.0
55
# Remove when support for Python 3.8 is dropped
66
mypy ==1.14.1; python_version < "3.9"
7-
mypy ==1.18.2; python_version >= "3.9"
8-
ruff ==0.14.8
7+
mypy ==1.19.1; python_version >= "3.9"
8+
ruff ==0.14.10
99
# For FastAPI tests
1010
fastapi >=0.103.2,<0.126.0
1111
httpx ==0.28.1

sqlmodel/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.0.27"
1+
__version__ = "0.0.29"
22

33
# Re-export from SQLAlchemy
44
from sqlalchemy.engine import create_engine as create_engine

sqlmodel/main.py

Lines changed: 62 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ def Field(
218218
*,
219219
default_factory: Optional[NoArgAnyCallable] = None,
220220
alias: Optional[str] = None,
221+
validation_alias: Optional[str] = None,
222+
serialization_alias: Optional[str] = None,
221223
title: Optional[str] = None,
222224
description: Optional[str] = None,
223225
exclude: Union[
@@ -263,6 +265,8 @@ def Field(
263265
*,
264266
default_factory: Optional[NoArgAnyCallable] = None,
265267
alias: Optional[str] = None,
268+
validation_alias: Optional[str] = None,
269+
serialization_alias: Optional[str] = None,
266270
title: Optional[str] = None,
267271
description: Optional[str] = None,
268272
exclude: Union[
@@ -317,6 +321,8 @@ def Field(
317321
*,
318322
default_factory: Optional[NoArgAnyCallable] = None,
319323
alias: Optional[str] = None,
324+
validation_alias: Optional[str] = None,
325+
serialization_alias: Optional[str] = None,
320326
title: Optional[str] = None,
321327
description: Optional[str] = None,
322328
exclude: Union[
@@ -352,6 +358,8 @@ def Field(
352358
*,
353359
default_factory: Optional[NoArgAnyCallable] = None,
354360
alias: Optional[str] = None,
361+
validation_alias: Optional[str] = None,
362+
serialization_alias: Optional[str] = None,
355363
title: Optional[str] = None,
356364
description: Optional[str] = None,
357365
exclude: Union[
@@ -390,43 +398,63 @@ def Field(
390398
schema_extra: Optional[Dict[str, Any]] = None,
391399
) -> Any:
392400
current_schema_extra = schema_extra or {}
401+
# Extract possible alias settings from schema_extra so we can control precedence
402+
schema_validation_alias = current_schema_extra.pop("validation_alias", None)
403+
schema_serialization_alias = current_schema_extra.pop("serialization_alias", None)
404+
field_info_kwargs = {
405+
"alias": alias,
406+
"title": title,
407+
"description": description,
408+
"exclude": exclude,
409+
"include": include,
410+
"const": const,
411+
"gt": gt,
412+
"ge": ge,
413+
"lt": lt,
414+
"le": le,
415+
"multiple_of": multiple_of,
416+
"max_digits": max_digits,
417+
"decimal_places": decimal_places,
418+
"min_items": min_items,
419+
"max_items": max_items,
420+
"unique_items": unique_items,
421+
"min_length": min_length,
422+
"max_length": max_length,
423+
"allow_mutation": allow_mutation,
424+
"regex": regex,
425+
"discriminator": discriminator,
426+
"repr": repr,
427+
"primary_key": primary_key,
428+
"foreign_key": foreign_key,
429+
"ondelete": ondelete,
430+
"unique": unique,
431+
"nullable": nullable,
432+
"index": index,
433+
"sa_type": sa_type,
434+
"sa_column": sa_column,
435+
"sa_column_args": sa_column_args,
436+
"sa_column_kwargs": sa_column_kwargs,
437+
**current_schema_extra,
438+
}
439+
if IS_PYDANTIC_V2:
440+
# explicit params > schema_extra > alias propagation
441+
field_info_kwargs["validation_alias"] = (
442+
validation_alias or schema_validation_alias or alias
443+
)
444+
field_info_kwargs["serialization_alias"] = (
445+
serialization_alias or schema_serialization_alias or alias
446+
)
447+
else:
448+
if validation_alias or schema_validation_alias is not None:
449+
raise RuntimeError("validation_alias is not supported in Pydantic v1")
450+
if serialization_alias or schema_serialization_alias is not None:
451+
raise RuntimeError("serialization_alias is not supported in Pydantic v1")
393452
field_info = FieldInfo(
394453
default,
395454
default_factory=default_factory,
396-
alias=alias,
397-
title=title,
398-
description=description,
399-
exclude=exclude,
400-
include=include,
401-
const=const,
402-
gt=gt,
403-
ge=ge,
404-
lt=lt,
405-
le=le,
406-
multiple_of=multiple_of,
407-
max_digits=max_digits,
408-
decimal_places=decimal_places,
409-
min_items=min_items,
410-
max_items=max_items,
411-
unique_items=unique_items,
412-
min_length=min_length,
413-
max_length=max_length,
414-
allow_mutation=allow_mutation,
415-
regex=regex,
416-
discriminator=discriminator,
417-
repr=repr,
418-
primary_key=primary_key,
419-
foreign_key=foreign_key,
420-
ondelete=ondelete,
421-
unique=unique,
422-
nullable=nullable,
423-
index=index,
424-
sa_type=sa_type,
425-
sa_column=sa_column,
426-
sa_column_args=sa_column_args,
427-
sa_column_kwargs=sa_column_kwargs,
428-
**current_schema_extra,
455+
**field_info_kwargs,
429456
)
457+
430458
post_init_field_info(field_info)
431459
return field_info
432460

@@ -1004,9 +1032,8 @@ def sqlmodel_update(
10041032
else:
10051033
value = getattr(obj, key)
10061034
setattr(self, key, value)
1007-
for remaining_key in use_update:
1035+
for remaining_key, value in use_update.items():
10081036
if remaining_key in get_model_fields(self):
1009-
value = use_update.pop(remaining_key)
10101037
setattr(self, remaining_key, value)
10111038
else:
10121039
raise ValueError(

0 commit comments

Comments
 (0)