Here is an example of how you would use this in practice. I've "mocked" an actual model (which mayis not actually required for this example use case but is implicitly required with the current class behavior):
You would adjust the dependency injection rules for your test to swap out the cursor_backend for this memory backend. This change is transparent to the model, sowhich you would use the model (and therefore memory backend) like this:
Note thatAnd it would pass the above MemoryTable class isn't used directly bycreate request down to the model. Rather, there is a MemoryBackend and, from there, to the above MemoryTable class that manages one of these "tables" for each model. The
There is a query builder automatically connects models and the backend, as well as generate the configuration for the eventual backend call. Therefore, if you used a query builder like this:
I can't decide if the lambda builder makes perfect sense, is impossible to read, or both. I also can't decide if there is a better approach. Also available The code lives here and there is further documentation under construction here.
I'm especially curious if there is a better, more readable approach (that doesn't make this take up a hundred extra lines of code or entail andan endless if/elif block), but of course I'm always up for any and all other suggestions!