 
 (defn get-tentacles-for-head
   [head]
-  (select tentacles-by-head
-          (where {:head_name (:name head)})))
+  (select tentacles
+          (with head-tentacle-mappings
+                (where {:head_name (:name head)}))))
 
 (defn create-tentacle!
   [tentacle]

  (belongs-to heads)
  (belongs-to tentacles))

(defentity tentacles-by-head
  (table (subselect head-tentacle-mappings
                    (join tentacles (= :head_tentacle_mappings.tentacle_name :tentacles.name))
                    (fields :head_tentacle_mappings.head_name
                            :tentacles.name
                            :tentacles.output_root
                            :tentacles.html_commands
                            :tentacles.source_control
                            :tentacles.entry_point))
         :tentacles_by_head)
  ;; These don't seem to have any effect and I have no idea why.
  (prepare ->snake-keys)
  (transform ->kebab-keys))

(defentity heads-by-tentacle
  (table (subselect head-tentacle-mappings
                    (join heads (= :head_tentacle_mappings.head_name :heads.name))
                    (fields :head_tentacle_mappings.tentacle_name :heads.name))
         :heads_by_tentacle))

(defn get-tentacle
  [name]
  (first (select tentacles

  (prepare add-updated)
  (prepare ->snake-keys)
  (transform ->kebab-keys)
  (has-many head-tentacle-mappings {:fk :head_name}))

;; ### Head <-> Tentacle Join Table
;; Heads and Tentacles can share the notorious SQL many-to-many
