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 MySQL support: TEXT columns cannot have a default value #415

Merged
merged 6 commits into from Nov 3, 2020
Merged

Fix MySQL support: TEXT columns cannot have a default value #415

merged 6 commits into from Nov 3, 2020

Conversation

natebeacham
Copy link
Contributor

@natebeacham natebeacham commented Oct 22, 2020

Hey there - just pulled down the latest published version and found out that the recent migrations don't seem to be mysql compatible.

This PR should resolve it be opting for null'ing the column:

Error for reference:

self = <_mysql.connection open to '127.0.0.1' at 0x5592d51818c0>
query = b"ALTER TABLE `explorer_query` ALTER COLUMN `description` SET DEFAULT ('')"
    def query(self, query):
        # Since _mysql releases GIL while querying, we need immutable buffer.
        if isinstance(query, bytearray):
            query = bytes(query)
>       _mysql.connection.query(self, query)
E       django.db.utils.OperationalError: (1101, "BLOB, TEXT, GEOMETRY or JSON column 'description' can't have a default value")

venv/lib/python3.8/site-packages/MySQLdb/connections.py:259: OperationalError

@marksweb
Copy link
Collaborator

Thanks for this @natebeacham

I think this was introduced by #337 which was for Oracle. It introduced a new migration which I think was similar to what you're talking about.

I've only got Postgres projects at the moment which were happy with it.

I guess that's short lived support for Oracle then!

@natebeacham
Copy link
Contributor Author

@marksweb Hey, thanks for the context. TBH, I don't think either null=True or default='' are really necessary, and we might get engine parity by omitting both. I'll test out another change.

@natebeacham
Copy link
Contributor Author

Hey @marksweb - I've made the changes, let me know what you think!

@marksweb
Copy link
Collaborator

marksweb commented Nov 2, 2020

@natebeacham Can you merge master into your branch please? I've organised the static files a little better & it's flagging as a conflict.

@natebeacham
Copy link
Contributor Author

@marksweb sure thing - done.

@marksweb marksweb merged commit 48fceba into chrisclark:master Nov 3, 2020
@MattFisher
Copy link
Contributor

FYI the previous version of the 0009_auto_20201009_0547 migration failed on our stack with django.db.utils.OperationalError: cannot ALTER TABLE "explorer_querylog" because it has pending trigger events using a Postgres 11.5 database that had existing data in the query and querylog tables.
I'm hoping this change will resolve the issue so we can upgrade to v2.

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.

None yet

4 participants