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

_get_dialects not working for properties #1858

Closed
markus-96 opened this issue Jan 22, 2025 · 0 comments
Closed

_get_dialects not working for properties #1858

markus-96 opened this issue Jan 22, 2025 · 0 comments

Comments

@markus-96
Copy link
Contributor

Describe the bug
Symptoms:

  1. Field.describe does not contain the correct db_field_types.
  2. CharField returns the wrong SQL_TYPE for oracle

It is only a small bug I think, but I wanted to share my findings.

To Reproduce

import json

from tortoise import Model
from tortoise.fields import CharField


class SomeModel(Model):
    some_field = CharField(max_length=255)


if __name__ == "__main__":
    print(json.dumps(SomeModel.describe(serializable=True)["data_fields"][0]["db_field_types"], indent=2))
    print(SomeModel._meta.fields_map.get('some_field')._get_dialects())
    print(SomeModel._meta.fields_map.get('some_field').get_for_dialect("oracle", "SQL_TYPE"))

outputs:

{
  "": "VARCHAR(255)"
}
{'oracle': {'field': <tortoise.fields.data.CharField object at 0x000001FB0578D370>}}
VARCHAR(255)

Expected behavior

{
  "": "VARCHAR(255)",
  "oracle": "NVARCHAR2(255)"
}
{'oracle': {'SQL_TYPE': 'NVARCHAR2(255)', 'field': <tortoise.fields.data.CharField object at 0x000001FB0578D370>}}
NVARCHAR2(255)

Additional context
Found this during fiddling around with #1853 ...

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

2 participants