Skip to content
Snippets Groups Projects
This project is mirrored from https://github.com/metabase/metabase. Pull mirroring updated .
  1. Apr 15, 2024
  2. Apr 12, 2024
  3. Apr 11, 2024
  4. Apr 10, 2024
    • Raphael Krut-Landau's avatar
    • adam-james's avatar
      Fix embed download endpoint (#41264) · 9cdf2340
      adam-james authored
      * Fix embed download endpoint
      
      We have added format_rows as a query parameter. In most endpoints this just works fine.
      
      Here, however, the problem is that we use query parameters to pass parameter values. We run some validation over these
      provided parameter values (eg. don't allow a user to over ride a 'locked' parameter). Since we have these 2 different
      use cases for query parameters, the validation was failing on :format_rows, which isn't expected to exist at all.
      
      Here, I dissoc the :format_rows key prior to this validation step, so normal validation can continue.
      
      * Add test that uses this card embedding endpoint
      Unverified
      9cdf2340
    • Alexander Solovyov's avatar
    • dpsutton's avatar
      Nested queries have limits which can defeat their purpose (#41051) · 2a8e19b2
      dpsutton authored
      * Nested queries have limits which can defeat their purpose
      
      Consider a query
      
      ```sql
      select count(*) from {{#199}}
      ```
      
      This query should return the number of distinct rows in the query
      defined by 199. But it's actually limited by the excel limit of
      1048575. And that's because when the value of `{{#199}}` is expanded it
      has that limit applied as normal.
      
      ```clojure
      qp=> (let [card-id 199] ;; use a valid card id for you
             (-> {:database 1,
                  :type :native,
                  :native {:query "select count(*) from {{ref}}"
                           :template-tags {:ref {:card-id card-id
                                                 :type :card
                                                 :name "ref"
                                                 :display-name "ref"}}}
                  :middleware {:disable-max-results? true}}
                 qp.compile/compile
                 :query
                 (metabase.db.query/format-sql )
                 println))
      select
        count(*)
      from
        (
          SELECT
            "PUBLIC"."ORDERS"."ID" AS "ID",
            "PUBLIC"."ORDERS"."TOTAL" AS "TOTAL"
          FROM
            "PUBLIC"."ORDERS"
          LIMIT
            1048575
        )
      ```
      
      But we can suppress this limit when substituting a query inside yielding
      
      ```sql
      select
        count(*)
      from
        (
          SELECT
            "PUBLIC"."ORDERS"."ID" AS "ID",
            "PUBLIC"."ORDERS"."TOTAL" AS "TOTAL"
          FROM
            "PUBLIC"."ORDERS"
        )
      ```
      
      And this is proper because we want to limit the _outer_ query, not
      internal queries.
      
      * Remove limit from test expectation
      
      * stupid trailing space
      
      * another subquery test
      
      * Use helper function to disable limit middleware
      Unverified
      2a8e19b2
Loading