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

fix: JSONField default value #362

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Matvey-Guzienko
Copy link

No description provided.

@henadzit
Copy link
Contributor

@Matvey-Guzienko, can you please add a test case exposing the issue?

@Matvey-Guzienko
Copy link
Author

@Matvey-Guzienko, can you please add a test case exposing the issue?

When adding a new JSONField to the table model and adding default=value, an empty field is created. This pull request solves this problem.

from tortoise import fields
from tortoise.models import Model


class TestModel(Model):
    id = fields.IntField(pk=True)

    testColumn = fields.JSONField(default={“testField”: “testValue”, “testField2”: “testValue2”})
tortoise.exceptions.OperationalError: (1064, “You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘’ at line 1”)

@henadzit
Copy link
Contributor

@Matvey-Guzienko can you please add a test exposing the issue as part of the PR? Otherwise, there is a chance that the issue will come back as a regression.

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

Successfully merging this pull request may close these issues.

2 participants