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

Unable to extend Result object #441

Open
dakujem opened this issue Sep 12, 2023 · 0 comments
Open

Unable to extend Result object #441

dakujem opened this issue Sep 12, 2023 · 0 comments

Comments

@dakujem
Copy link
Contributor

dakujem commented Sep 12, 2023

This is a design problem:
IConnection interface's method IConnection::query is coupled with a concrete implementation (Result) that is not extensible in any meaningful way.

We need to be able to provide our own result objects. Now since IConnection::query only allows returning Result and subclassing Result is useless because of private props and final methods, we are not able to do so.
Even implementing one's own IConnection will not work because of the interface.

Currently, the only possible solution is not to use the interface and proxy the calls - for the whole Connection and Result classes. This is tedious and leads to possible bugs. Plus any code expecting IConnection, Connection or Result is unusable.

Possible solution

  • private --> protected and remove the final keywords
  • come up with an interface for Result objects

The actual use-case

Under special circumstances I do not want any exceptions to be thrown while using Dibi for DB querying.
Without relying on the calling code to be responsible for wrapping the calls with try-catch blocks.

This is currently not possible due to the aforementioned design limitation.
It would normally be very easy to just extend the Connection and Result classes and wrap the internal parent calls with try-catch blocks.

This is arguably an edge-case,
but there's more use-cases for simply being able to extend Dibi. For example #357 demonstrates one where it would be easy to come up with own solution, but it's not possible as it stands now.

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

No branches or pull requests

1 participant