-
-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Problem
Currently, Mito does not seem to support specifying the sort order (ASC or DESC) for columns within an index definition. It appears that deftable only accepts a list of column names (symbols or strings) for :keys and :unique-keys.
When dealing with large tables, it is often necessary to create composite indexes with mixed sort orders (e.g., (category_id ASC, score DESC)) to optimize specific queries (e.g., ORDER BY category_id ASC, score DESC).
Current Limitation
If I attempt to pass a list specifying the order, such as (:desc :score), Mito raises an error because the current implementation expects simple column names.
Proposed Feature
It would be great if Mito could support a syntax to specify the sort order in deftable (or defclass).
Example Syntax:
(mito:deftable user-scores ()
((user-id :col-type :bigint)
(score :col-type :integer)
(created-at :col-type :timestamp))
;; Proposal: Allow (:desc column-name) or (:asc column-name) in keys
(:keys (user-id (:desc score))))Expected SQL (e.g. MySQL/PostgreSQL):
CREATE INDEX index_name ON user_scores (user_id, score DESC);