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

Conversation

sevdog
Copy link
Contributor

@sevdog sevdog commented May 25, 2021

As of now HexIntegerField relies on connection.settings_dict["ENGINE"] to determinate if the database supports specific feature.

Since a custom engine may be defined by any user this has some limitation because engines are hard-coded.

The preferred approach would be to use connection.feature_class.<feature>, but ATM there is no flag in these classes which may help here (ie: supports_unsigned_integers).

My solution here is to rely on connection.vendor because it should be more robust and could handle subclassing of any existent backend, if that backend has some kind of differences it could just override vendor attribute (ie: postgresql -> custom-postgresql).

Also this saves us some configurations since django.db.backends.postgresql, django.db.backends.postgresql_psycopg2 and django.contrib.gis.db.backends.postgis have all vendor = "posrgresql", and we also get spatiallite (which is based on sqlite and has the same datatypes).

@codecov
Copy link

codecov bot commented May 25, 2021

Codecov Report

Merging #612 (217d5b0) into master (13a2c6f) will decrease coverage by 0.02%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #612      +/-   ##
==========================================
- Coverage   68.30%   68.27%   -0.03%     
==========================================
  Files          24       24              
  Lines        1101     1100       -1     
  Branches      173      173              
==========================================
- Hits          752      751       -1     
  Misses        312      312              
  Partials       37       37              
Impacted Files Coverage Δ
push_notifications/fields.py 60.93% <50.00%> (-0.61%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13a2c6f...217d5b0. Read the comment docs.

@auvipy auvipy merged commit 31810d0 into jazzband:master Nov 11, 2021
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

3 participants