    (s/optional-key :breakout)    [FieldPlaceholder]
    (s/optional-key :fields)      [FieldPlaceholderOrAgRef]
    (s/optional-key :filter)      Filter
-   (s/optional-key :limit)       s/Int
+   (s/optional-key :limit)       IntGreaterThanZero
    (s/optional-key :order-by)    [OrderBy]
    (s/optional-key :page)        Page
-   :source-table                 s/Int})
+   :source-table                 IntGreaterThanZero})

;;; # ------------------------------------------------------------ "RESOLVED" TYPES: FIELD + VALUE ------------------------------------------------------------

;; Field is the expansion of a Field ID in the standard QL
(s/defrecord Field [field-id           :- s/Int
                    field-name         :- s/Str
                    field-display-name :- s/Str
                    base-type          :- (apply s/enum field/base-types)
                    special-type       :- (s/maybe (apply s/enum field/special-types))
                    table-id           :- s/Int
                    schema-name        :- (s/maybe s/Str)
                    table-name         :- s/Str
                    position           :- (s/maybe s/Int)
                    description        :- (s/maybe s/Str)
                    parent-id          :- (s/maybe s/Int)
                    ;; Field once its resolved; FieldPlaceholder before that
                    parent             :- s/Any]
  IField


;; These are just used by the QueryExpander to record information about how joins should occur.

(def IntGreaterThanZero (s/constrained s/Int
                                       (partial < 0)
                                       "Integer greater than zero"))

(s/defrecord JoinTableField [field-id   :- IntGreaterThanZero
                             field-name :- s/Str])

(s/defrecord JoinTable [source-field :- JoinTableField
                        pk-field     :- JoinTableField
                        table-id     :- IntGreaterThanZero
                        table-name   :- s/Str])

;;; # ------------------------------------------------------------ PROTOCOLS ------------------------------------------------------------
