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

Change feature detection logic for database field #612

Merged
merged 1 commit into from Nov 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 6 additions & 9 deletions push_notifications/fields.py
Expand Up @@ -14,16 +14,14 @@


hex_re = re.compile(r"^(([0-9A-f])|(0x[0-9A-f]))+$")
signed_integer_engines = [
"django.db.backends.postgresql",
"django.db.backends.postgresql_psycopg2",
"django.contrib.gis.db.backends.postgis",
"django.db.backends.sqlite3"
signed_integer_vendors = [
"postgresql",
"sqlite",
]


def _using_signed_storage():
return connection.settings_dict["ENGINE"] in signed_integer_engines
return connection.vendor in signed_integer_vendors


def _signed_to_unsigned_integer(value):
Expand Down Expand Up @@ -79,10 +77,9 @@ class HexIntegerField(models.BigIntegerField):
]

def db_type(self, connection):
engine = connection.settings_dict["ENGINE"]
if "mysql" in engine:
if "mysql" == connection.vendor:
return "bigint unsigned"
elif "sqlite" in engine:
elif "sqlite" == connection.vendor:
return "UNSIGNED BIG INT"
else:
return super(HexIntegerField, self).db_type(connection=connection)
Expand Down