diff --git a/index.html b/index.html index 24077d9..81166d9 100644 --- a/index.html +++ b/index.html @@ -11725,7 +11725,7 @@
(defmethod ->honeysql [:sql :field] - [driver [_ id-or-name {:keys [database-type] - ::nest-query/keys [outer-select] - :as options} + [driver [_ id-or-name {:keys [database-type] :as options} :as field-clause]] (try (let [source-table-aliases (field-source-table-aliases field-clause) @@ -36514,7 +36512,7 @@`:abstract?` (default = false)
field (when (integer? id-or-name) (lib.metadata/field (qp.store/metadata-provider) id-or-name)) allow-casting? (and field - (not outer-select)) + (not (:qp/ignore-coercion options))) database-type (or database-type (:database-type field)) ;; preserve metadata attached to the original field clause, for example BigQuery temporal type information. @@ -36833,8 +36831,8 @@`:abstract?` (default = false)
true (assoc ::add/source-alias (::add/desired-alias opts) ::add/source-table ::add/none - ;; sort of a HACK but this key will tell the SQL QP not to apply casting here either. - ::nest-query/outer-select true + ;; this key will tell the SQL QP not to apply casting here either. + :qp/ignore-coercion true ;; used to indicate that this is a forced alias ::forced-alias true) ;; don't want to do temporal bucketing or binning inside the order by only. @@ -79556,20 +79554,22 @@`:fallback`
"Get implicit Fields for a query with a `:source-query` that has `source-metadata`." [source-metadata :- [:sequential {:min 1} mbql.s/SourceQueryMetadata]] (distinct - (for [{field-name :name, base-type :base_type, field-id :id, [ref-type :as field-ref] :field_ref} source-metadata] + (for [{field-name :name, base-type :base_type, field-id :id, [ref-type :as field-ref] :field_ref coercion-strategy :coercion_strategy} source-metadata] ;; return field-ref directly if it's a `:field` clause already. It might include important info such as ;; `:join-alias` or `:source-field`. Remove binning/temporal bucketing info. The Field should already be getting - ;; bucketed in the source query; don't need to apply bucketing again in the parent query. + ;; bucketed in the source query; don't need to apply bucketing again in the parent query. Mark the field as + ;; `qp/ignore-coercion` here so that it doesn't happen again in the parent query. (or (some-> (mbql.u/match-one field-ref :field) - (mbql.u/update-field-options dissoc :binning :temporal-unit)) + (mbql.u/update-field-options dissoc :binning :temporal-unit) + (cond-> coercion-strategy (mbql.u/assoc-field-options :qp/ignore-coercion true))) ;; otherwise construct a field reference that can be used to refer to this Field. ;; Force string id field if expression contains just field. See issue #28451. (if (and (not= ref-type :expression) field-id) ;; If we have a Field ID, return a `:field` (id) clause - [:field field-id nil] + [:field field-id (cond-> nil coercion-strategy (assoc :qp/ignore-coercion true))] ;; otherwise return a `:field` (name) clause, e.g. for a Field that's the result of an aggregation or - ;; expression + ;; expression. We don't need to mark as ignore-coercion here because these won't grab the field metadata [:field field-name {:base-type base-type}])))))
Whether we should add implicit Fields to this query. True if all of the following are true: