Possibly detect adapter support for recursive queries
Opened this issue · 1 comments
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:
- 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.
- 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.
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.