jazzband / django-push-notifications

Send push notifications to mobile devices through GCM or APNS in Django.
MIT License
2.26k stars 613 forks source link

Change feature detection logic for database field #612

Closed sevdog closed 2 years ago

sevdog commented 3 years ago

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[bot] commented 3 years ago

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%) :arrow_down:

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.