-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: support AUTO_ID_CACHE #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As AUTO_ID_CACHE=1
makes things more MySQL compatible... should we consider making that the default? As this isn't the default in TiDB I don't think we should, but maybe others have different opinions on this?
sql, params = super().table_sql(model) | ||
tidb_auto_id_cache = getattr(model._meta, "tidb_auto_id_cache", None) | ||
if tidb_auto_id_cache is not None: | ||
sql += " AUTO_ID_CACHE %s" % tidb_auto_id_cache |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if tidb_auto_id_cache
isn't a number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The user will receive an error thrown by django-tidb or TiDB, Django does not provide a way to validate meta option, its built-in option can also result in error when got invalid value.
Do we need the |
Seems after v6.4.0 make it default doesn't hurt anything. |
I think has |
I have added a |
048bfec
to
453d091
Compare
I revert the above change, because |
Refer to #52
This PR plans to support
AUTO_ID_CACHE
in Django by declaring it in the model's meta option.Note:
tidb_auto_id_cache
only affects table creation.For example:
This PR also removed
functions.py
because we have already revertedDatabaseWrapper.vendor
to mysql, so there is no need to patch the as_tidb function anymore.