Skip to content

Commit

Permalink
closql--remake-instances: New function
Browse files Browse the repository at this point in the history
It is convenient to have this available when implementing
`closql-dref' methods.
  • Loading branch information
tarsius committed Jun 23, 2024
1 parent 749b4da commit ffbd489
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions closql.el
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@
((not (eq value eieio--unbound)) value)
((setq class (closql--slot-class obj slot))
(aset obj c
(mapcar (lambda (row) (closql--remake-instance class db row))
(emacsql db `[:select * :from $i1
:where (= $i2 $s3)
:order-by
,(or (oref-default class closql-order-by)
[(asc $i4)])]
(oref-default class closql-table)
(oref-default class closql-foreign-key)
(closql--oref
obj (oref-default obj closql-primary-key))
(oref-default class closql-primary-key)))))
(closql--remake-instances class db
(emacsql db `[:select * :from $i1
:where (= $i2 $s3)
:order-by
,(or (oref-default class closql-order-by)
[(asc $i4)])]
(oref-default class closql-table)
(oref-default class closql-foreign-key)
(closql--oref
obj (oref-default obj closql-primary-key))
(oref-default class closql-primary-key)))))
((setq table (closql--slot-table obj slot))
(let ((columns (closql--table-columns db table)))
(aset obj c
Expand Down Expand Up @@ -454,6 +454,12 @@
(closql--resolve-slots obj))
obj))

(defun closql--remake-instances (class db rows)
(declare (indent defun))
(mapcar (lambda (row)
(closql--remake-instance class db row))
rows))

(cl-defmethod closql--resolve-slots ((obj closql-object))
(dolist (slot (eieio-class-slots (eieio--object-class obj)))
(setq slot (cl--slot-descriptor-name slot))
Expand Down

0 comments on commit ffbd489

Please sign in to comment.