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

Introduce driver.execute_query #833

Merged
merged 17 commits into from
Jan 26, 2023
Merged

Conversation

robsdedude
Copy link
Member

@robsdedude robsdedude commented Oct 17, 2022

Copy link
Contributor

@bigmontz bigmontz left a comment

Choose a reason for hiding this comment

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

🥇

(Just minor comments)

docs/source/api.rst Outdated Show resolved Hide resolved
neo4j/_async/driver.py Outdated Show resolved Hide resolved
neo4j/_async/driver.py Outdated Show resolved Hide resolved
neo4j/_async/work/result.py Outdated Show resolved Hide resolved
:returns: the result of the ``result_transformer``
:rtype: T

.. versionadded:: 5.2
Copy link
Member Author

Choose a reason for hiding this comment

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

⚠️ before merging: make sure to adjust all of these!

:members: session, query_bookmark_manager, encrypted, close,
verify_connectivity, get_server_info

.. method:: execute_query(query, parameters=None,routing=neo4j.RoutingControl.WRITERS, database=None, impersonated_user=None, bookmark_manager=self.query_bookmark_manager, result_transformer=Result.to_eager_result, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a :raises: field? Or does it raise too many different exceptions?

Copy link
Member Author

@robsdedude robsdedude Oct 31, 2022

Choose a reason for hiding this comment

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

There are plenty of errors this can raise. Here are the one's I can think of on the spot

  • Neo4jError (or any sub-class) - anything the server complains about
  • SessionExpired, ServiceUnavailable (or any sub-class) - lost/couldn't establish connectivity (after the retries this API includes)
  • ConfigurationError TypeError ValueError (maybe even IndexError?) - invalid configuration/parameters or trying to use a feature that's too new for the server you're connected to
  • BoltError (or any sub-class; internal error class you shouldn't ever encounter) - the server violated the protocol

There might be more that I can't think of right now. My conclusion:

  • All of there errors are fatal (there is pretty much no benefit in giving them different treatment). The user might as well just catch any exception, maybe log it or whatever they feel doing, and then give up (that could mean crash, surface some error to the end-user, whatever is suitable). Plus maybe fixing their code afterwards.
  • I can hardly give any guarantees what errors this method can raise as it pretty much exercises the whole stack of the driver. It's highly likely that I'll forget some corner of the driver and, even if not, that this piece of documentation will unsync sooner or later as it's so far up the abstraction stack.

So much for why I didn't include it. If you think it'd be helpful nonetheless, we can make it happen.

Copy link
Contributor

Choose a reason for hiding this comment

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

The user might as well just catch any exception

👍

@robsdedude robsdedude mentioned this pull request Nov 1, 2022
5 tasks
Copy link
Contributor

@bigmontz bigmontz left a comment

Choose a reason for hiding this comment

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

🌵 🌵 🌵

@robsdedude robsdedude merged commit f121154 into neo4j:5.0 Jan 26, 2023
@robsdedude robsdedude deleted the driver-level-api branch January 26, 2023 14:52
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.

3 participants