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

Possibly detect adapter support for recursive queries #17

Open
danielkza opened this issue Sep 7, 2015 · 1 comment
Open

Possibly detect adapter support for recursive queries #17

danielkza opened this issue Sep 7, 2015 · 1 comment

Comments

@danielkza
Copy link

Would it be feasible to attempt to detect support for recursive queries from the database adapter, an revert to a naive approach if it isn't available? This way it would be possible to use edge with SQLite and MySQL without needing any changes in client code.

I have two ideas on how this could be implemented:

  1. Run a test query the first time a recursive query needs to be performed, and store whether it succeeded or not in a per-adapter module-wide variable. Then use that to decide what approach to use for subsequent queries.
  2. Attempt to catch syntax errors on recursive query execution, fallback to the naive approach, and also cache the failure as above.

If this is desirable and not considered to hacky I can do it and send a PR.

@jackc
Copy link
Owner

jackc commented Sep 8, 2015

It would be cool, but I think it may be harder than it initially appears.

For example, given the approach of trying a recursive query and recovering on error. What happens if the client code is already in a transaction? It could break the transaction and cause all future statements to fail until rollback. Possibly nested transactions or save points could solve this, but I do not know how widely they are supported. I think there will be a few other sharp edges as well.

So if you can get it to work, it would be a great feature, but getting it to work reliably may be tricky.

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

2 participants