Korma と MySQL を使用して、posts という名前のテーブルから選択しようとしています。デフォルトでは nil である公開日のフィールドがあります。
mysql> describe posts;
+-----------+--------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+--------------+------+-----+---------------------+-------+
| id | int(11) | NO | PRI | 0 | |
| title | varchar(250) | YES | | NULL | |
| content | text | YES | | NULL | |
| status | tinyint(1) | YES | | 0 | |
| created | timestamp | NO | | CURRENT_TIMESTAMP | |
| published | timestamp | NO | | 0000-00-00 00:00:00 | |
| author | int(11) | NO | MUL | NULL | |
+-----------+--------------+------+-----+---------------------+-------+
7 rows in set (0.02 sec)
公開されたフィールドを選択して使用しようとすると、次のエラーが発生します。
user=> (select posts (fields :id :title :content :status :created : published )) SQL でクエリを実行できない: SELECT posts.id, posts.title, posts.content, posts.status, posts.created, posts.published FROM posts :: [] ClassCastException java.lang.RuntimeException は java.sql.SQLException にキャストできません clojure.java.jdbc/print-sql-exception (jdbc.clj:350)
公開されたフィールドを使用しない場合、すべて正常に動作します:
user=> (select posts (fields :id :title :content :status :created :author)) [{:id 1, :title "Hello World!", :content "世界で最も先進的な Clojure Beat Engine、Beats へようこそ! ", :status true, :created #, :author 1} {:id 2, :title "Hello World!, again!", :content "Sayin 't 'gain! Beats へようこそ。世界で最も先進的な Clojure Beat Engine! ", :status true, :created #, :author 2}]
このフィールドをどのように処理できますか? 単純なログ ステートメントだけで変換関数をエンティティに追加しようとしましたが、呼び出されないようです。