cl-deck-builder2/tests/models/ygo-import.lisp

21 lines
808 B
Common Lisp
Raw Normal View History

2024-01-21 02:35:35 -05:00
(in-package #:cl-deck-builder2-test)
(defun ensure-unique (class field)
"The idea is to select COUNT(*) and then GROUP BY (field) and see if
the number of entries returned is the same."
(let ((count-1
(with-datafly-transaction (db)
(datafly:retrieve-one
(sxql:select ((:as (:count :id) :count))
(sxql:from
(sxql:make-sql-symbol (mito.class:table-name (find-class class))))))))
(count-2
(with-datafly-transaction (db)
(datafly:retrieve-one
(sxql:select ((:as (:count :id) :count))
(sxql:from
(sxql:make-sql-symbol (mito.class:table-name (find-class class))))
(sxql:group-by field))))))
(eq (getf count-1 :count)
(getf count-2 :count))))