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

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

Merged

Conversation

GnaneshKunal
Copy link
Contributor

@GnaneshKunal GnaneshKunal commented May 6, 2021

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.

GRAPH.QUERY when the command is not found.
Comment on lines 180 to 184
if "unknown command" in str(e):
# `GRAPH.RO_QUERY` is unavailable in older versions.
command[0] = "GRAPH.QUERY"
response = self.redis_con.execute_command(*command)
return QueryResult(self, response)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check to see if read_only is True if so
recall return self.query(q, params, timeout, read_only=False)

@GnaneshKunal GnaneshKunal force-pushed the fix-graph-ro-query-regression branch from 6663475 to f57ceb4 Compare May 6, 2021 11:01
@sonarqubecloud
Copy link

sonarqubecloud bot commented May 6, 2021

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

@swilly22 swilly22 merged commit 4e2be1e into RedisGraph:master May 7, 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.

Unknown command GRAPH.RO_QUERY
2 participants