RedisGraph / redisgraph-py

RedisGraph python client
https://redisgraph.io
BSD 3-Clause "New" or "Revised" License
189 stars 49 forks source link

Fall back to GRAPH.QUERY when `GRAPH.RO_QUERY` is not available. #124

Closed GnaneshKunal closed 3 years ago

GnaneshKunal commented 3 years ago

Fix: #123

GRAPH.RO_QUERY is unavailable in older versions. So fallback to GRAPH.QUERY when the command is not found.

While there's a way to always use GRAPH.QUERY by setting read_only to False, methods that try to fetch the labels and other properties are hardcoded to True.

    def labels(self):
        return self.call_procedure("db.labels", read_only=True).result_set

    def relationshipTypes(self):
        return self.call_procedure("db.relationshipTypes", read_only=True).result_set

    def propertyKeys(self):
        return self.call_procedure("db.propertyKeys", read_only=True).result_set

While we can have a param read_only to the above methods, introducing the same would actually change many methods that is calling the above methods directly or indirectly to have read_only param and that's huge.

So checking for unknown command while executing the query makes it a simple fix.

sonarcloud[bot] commented 3 years ago

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication