Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pydantic validation error when inspecting DB #322

Open
a-babarytskyi opened this issue Aug 29, 2023 · 4 comments
Open

Pydantic validation error when inspecting DB #322

a-babarytskyi opened this issue Aug 29, 2023 · 4 comments

Comments

@a-babarytskyi
Copy link

When inspecting db (after all migrations) getting this error:

Stack trace:

Traceback (most recent call last):
  File "/usr/local/bin/aerich", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aerich/cli.py", line 265, in main
    cli()
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aerich/cli.py", line 31, in wrapper
    loop.run_until_complete(f(*args, **kwargs))
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aerich/cli.py", line 260, in inspectdb
    ret = await command.inspectdb(table)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aerich/__init__.py", line 124, in inspectdb
    return await inspect.inspect()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aerich/inspectdb/__init__.py", line 95, in inspect
    columns = await self.get_columns(table)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aerich/inspectdb/postgres.py", line 62, in get_columns
    Column(
  File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 165, in __init__
    __pydantic_self__.__pydantic_validator__.validate_python(data, self_instance=__pydantic_self__)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Column
extra
  Field required [type=missing, input_value={'name': 'id', 'data_type...: False, 'index': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.3/v/missing

Libs:

  • aerich==0.7.2
  • asyncpg==0.28.0
  • tortoise-orm==0.20.0
  • pydantic==2.3.0
  • pydantic_core==2.6.3

Not sure which additional info to provide. All tables have custom names with Meta class, also I have 2 custom field types:

class NativeDatetimeField(Field[datetime.datetime], datetime.datetime):
    SQL_TYPE = "timestamp without time zone"

class NativeDatetimeFieldNow(Field[datetime.datetime], datetime.datetime):
    SQL_TYPE = "timestamp without time zone DEFAULT now()"

Any suggestions what could it be?

long2ice added a commit that referenced this issue Aug 30, 2023
@long2ice
Copy link
Member

Please try latest source code.

@edimedia
Copy link

Hi log2ice, you are right when you saying that we must latest source code but when i'm trying
pip install aerich
the latest version is 0.7.2, and the pydantic validation error persists, and when i'm checking the code on github i can see the problem is solved, and i think so, the author have to update the python (pypi) repository please.

@pg
Copy link

pg commented Aug 16, 2024

Yes, I see the same issue. When will there be another release?

aerich inspectdb
...
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 4 validation errors for Column
comment
  Field required [type=missing, input_value={'name': 'id', 'data_type...: False, 'index': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.8/v/missing
extra
  Field required [type=missing, input_value={'name': 'id', 'data_type...: False, 'index': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.8/v/missing
decimal_places
  Field required [type=missing, input_value={'name': 'id', 'data_type...: False, 'index': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.8/v/missing
max_digits
  Field required [type=missing, input_value={'name': 'id', 'data_type...: False, 'index': False}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.8/v/missing

@tomas-aftalion
Copy link

tomas-aftalion commented Aug 21, 2024

Same error here for 0.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants