Skip to content

Commit

Permalink
Generate IS NULL query by specifying NIL in key-value style query…
Browse files Browse the repository at this point in the history
… functions.

* `find-dao`
* `retrieve-dao`
* `count-dao`
* `delete-by-values`
  • Loading branch information
fukamachi committed Jun 28, 2024
1 parent 31393c4 commit 6fa9836
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/core/dao.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
#:find-slot-by-name
#:find-parent-column
#:find-child-columns
#:table-name
#:table-column-references-column
#:table-column-name
#:table-column-type)
#:table-column-type
#:table-column-not-null-p)
(:import-from #:mito.db
#:last-insert-id
#:execute-sql
Expand Down Expand Up @@ -347,8 +349,17 @@
(c2mop:slot-definition-name
(table-column-references-column child)))))))))
else
collect `(:= ,(unlispify field)
,(dao-table-column-deflate slot value)))))
collect (let ((db-value
(dao-table-column-deflate slot value)))
(cond
((null db-value)
(unless (table-column-not-null-p slot)
(warn "Slot ~S in table ~A is not null, but a condition specified IS NULL."
(table-column-name slot)
(table-name class)))
`(:is-null ,(unlispify field)))
(t
`(:= ,(unlispify field) ,db-value)))))))
(when op
(sxql:where `(:and ,@op))))))

Expand Down

0 comments on commit 6fa9836

Please sign in to comment.