    get the record from the primary table"
 
   [session ^Model model table record-or-key-value opts]
-  (let [lkv (k/extract-key-value (:key table) record-or-key-value opts)
-        lr-def (r/select-one session (:name table) (:key table) lkv)]
-    (d/chain lr-def
-             (fn [lr]
-               (when lr ;; ignore dangling lookups
-                 (when-let [pkv (k/extract-key-value
-                                 (get-in model [:primary-table :key])
-                                 lr)]
-                   (r/select session
-                             (get-in model [:primary-table :name])
-                             (get-in model [:primary-table :key])
-                             pkv
-                             (dissoc opts :key-value))))))))
+  (let [lkv (k/extract-key-value (:key table) record-or-key-value opts)]
+    (m/with-monad dm/either-deferred-monad
+      (m/mlet [lr (r/select-one session (:name table) (:key table) lkv)
+               pkv (m/return
+                    (when lr
+                      (t/extract-uber-key-value model lr)))]
+              (if pkv
+                (r/select session
+                          (get-in model [:primary-table :name])
+                          (get-in model [:primary-table :key])
+                          pkv
+                          (dissoc opts :key-value))
+                (m/return nil))))))
 
 (defn select
   "select records from primary or lookup tables as required"

                               record-or-key-value
                               opts)

       (if-let [lookup-table (if-lookup-key-table model key)]

         (select-from-lookup-table session
                                   model

(ns er-cassandra.model.select
  (:require [manifold.deferred :as d]
            [cats.core :as m]
            [cats.monad.either :as either]
            [cats.monad.deferred :as dm]
            [qbits.alia :as alia]
            [qbits.alia.manifold :as aliam]
            [qbits.hayt :as h]
            [er-cassandra.key :as k]
            [er-cassandra.record-either :as r]
            [er-cassandra.model.types :as t])
  (:import [er_cassandra.model.types Model]))

(defn if-primary-key-table
