art049 / art049/odmantic

regex is removed in pydantic 2.x this causes the Field class to throw an exception if its used.

Open
#397 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1.2k
Forks
97
PR merge metrics
No merged PRs in 30d

Description

# Bug

if you define a field like
```
email: str = Field(regex=RE_EMAIL_PATTERN)
```
The program when run gives the following exception:-

```
pydantic.errors.PydanticUserError: `regex` is removed. use `pattern` instead
```

### Current Behavior

just define a Field that has a regex defined

### Expected behavior

it would be good to align with Pydantic and support the patten keyword argument

### Environment

- ODMantic version: 1.0.0
- MongoDB version: 7.0.2
- Pydantic infos:
pydantic version: 2.5.2
pydantic-core version: 2.14.5
pydantic-core build: profile=release pgo=true
python version: 3.12.1 (main, Dec 10 2023, 13:40:31) [Clang 15.0.0 (clang-1500.0.40.1)]
platform: macOS-14.1.2-arm64-arm-64bit
related packages: fastapi-0.105.0 typing_extensions-4.9.0 pydantic-settings-2.1.0

```
...
```

- Version of additional modules (if relevant):
- ...

**Additional context**

_Add any other context about the problem here._

Contributor guide

Open the contributing guide

Research direction

Start by locating ODMantic's Field entry point and how it forwards the regex argument to Pydantic. Confirm the behavior against the reported Pydantic 2.5.2 error, then verify that the pattern keyword is accepted without raising the removed-regex exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.