Query row limit doesn't limit in-product downloads (#37716)
I misunderstood the desired behavior when I implemented this before. We only want the limit to apply when the `add-default-userland-constraints` middleware is applied to the query, not when we're downloading the data directly. This is a bit of a rat's nest. If there's a better way to approach the problem, I'd be happy to hear it. I added documentation for the odd approach as much as possible. The main difficulty is that the userland middleware does not have access to db-local settings. So if we want db-local settings to apply only to userland, we have to hack our way around it. The solution here is to divide the userland middleware into two parts: - the actually-userland bit, which just marks the query as needing default limits, and - a middleware inserted deeper in the middleware stack (just before we actually apply limits) that actually calculates those limits and attaches them to the query.
Showing
- modules/drivers/sqlserver/test/metabase/driver/sqlserver_test.clj 1 addition, 5 deletions...drivers/sqlserver/test/metabase/driver/sqlserver_test.clj
- src/metabase/query_processor.clj 2 additions, 1 deletionsrc/metabase/query_processor.clj
- src/metabase/query_processor/middleware/constraints.clj 37 additions, 16 deletionssrc/metabase/query_processor/middleware/constraints.clj
- src/metabase/query_processor/middleware/limit.clj 4 additions, 11 deletionssrc/metabase/query_processor/middleware/limit.clj
- test/metabase/query_processor/middleware/constraints_test.clj 13 additions, 6 deletions.../metabase/query_processor/middleware/constraints_test.clj
Please register or sign in to comment