@cached_property is only evaluated if it's attached to an instance. The current feature checks are implemented by mapping connection.vendor to the [vendor]Featuresclass es. However, since we don't create an instance of the [vendor]Features classes, calling features[connection.vendor].feature_name returns a cached_property object, not the evaluated value.
A better implementation would be to use @receiver(connection_created) and use setattr() to add JSON features to connection.features, so that feature checks would be similar to the built-in JSONField.
It's probably a good idea to also add another test matrix with a database that does not support JSONField.
@cached_property
is only evaluated if it's attached to an instance. The current feature checks are implemented by mappingconnection.vendor
to the[vendor]Features
class
es. However, since we don't create an instance of the[vendor]Features
classes, callingfeatures[connection.vendor].feature_name
returns acached_property
object, not the evaluated value.A better implementation would be to use
@receiver(connection_created)
and usesetattr()
to add JSON features toconnection.features
, so that feature checks would be similar to the built-in JSONField.It's probably a good idea to also add another test matrix with a database that does not support JSONField.