(ns metabase-enterprise.snippet-collections.api.native-query-snippet
  (:require
   [metabase.public-settings.premium-features :refer [defenterprise]]
   [metabase.util.honey-sql-2 :as h2x]))

Clause to filter out snippet collections from the collection query on OSS instances, and instances without the snippet-collections feature flag. EE implementation returns nil, so as to not filter out snippet collections.

(defenterprise snippets-collection-filter-clause
  :feature :snippet-collections
  [])

Collection children query for snippets on EE.

(defenterprise snippets-collection-children-query
  :feature :snippet-collections
  [collection {:keys [archived?]}]
  {:select [:id :collection_id :name :entity_id [(h2x/literal "snippet") :model]]
   :from   [[:native_query_snippet :nqs]]
   :where  [:and
            [:= :collection_id (:id collection)]
            [:= :archived (boolean archived?)]]})