 
                                 (merge
                                  (choose-lookup-additional-cols
-                                  model with-cols old-record record)
+                                  entity with-cols old-record record)
 
                                  lookup-record))]
             lookup-record))))))

   - record: upserted primary-table record to generate lookups for
             (or nil for deletion)"
  [session :- ModelSession
   model :- Entity
   table :- t/IndexTableSchema
   old-record :- t/MaybeRecordSchema
   record :- t/MaybeRecordSchema]
  (if record
    (default-lookup-record-generator-for-key-fn
     model table (:key table) old-record record)
    []))

(s/defn generate-lookup-records-for-table
  "generate all the lookup records for one lookup table"
  [session :- ModelSession
   model :- Entity
   {generator-fn :generator-fn
    :as table} :- t/IndexTableSchema
   old-record :- t/MaybeRecordSchema
   record :- t/MaybeRecordSchema]
  ((or generator-fn
       default-lookup-record-generator-fn)
   session model table old-record record))

(s/defn stale-lookup-key-values-for-table
  [session :- ModelSession

   - old-record: previous primary table record (or nil for new)
   - record: upserted primary-table record to generate lookups for
             (or nil for deletion)"
  [entity
   table
   key
   old-record
   record]
  (let [uber-key (t/uber-key entity)
        uber-key-value (or
                        (k/extract-key-value uber-key record)
                        (k/extract-key-value uber-key old-record))
