   (let [entids (zipmap (vals (dm/idents db)) (keys (dm/idents db)))]
     (go-pair
       (->>
-        (s/all-rows (:sqlite-connection db) ["SELECT e, a, v, tx FROM datoms WHERE tx >= ?" tx])
+        (s/all-rows (:sqlite-connection db) ["SELECT e, a, v, tx FROM datoms WHERE tx > ?" tx])
         (<?)
         (mapv #(vector (:e %) (get entids (:a %) (str "fail" (:a %))) (:v %)))
         (filter #(not (= :db/txInstant (second %))))

          now  0xdeadbeef
          tempids (fn [tx] (into {} (map (juxt (comp :idx first) second) (:tempids tx))))]
      (try
        (is (not (= nil (<? (dm/<transact! conn test-schema now)))))

        ;; Not having DB-as-value really hurts us here.  This test only works because all upserts
        ;; succeed on top of each other, so we never need to reset the underlying store.
        (<? (dm/<transact! conn test-schema now))
        (<? (dm/<transact! conn [{:db/id 101 :name "Ivan" :email "@1"}
                                 {:db/id 102 :name "Petr" :email "@2"}] now))

        (testing "upsert with tempid"
          (let [report (<? (dm/<transact! conn [[:db/add (dm/id-literal :db.part/user -1) :name "Ivan"]
                                                [:db/add (dm/id-literal :db.part/user -1) :age 12]] now))]
            (is (= (<? (<shallow-entity (dm/db conn) 101))
                   {:name "Ivan" :age 12 :email "@1"}))
            (is (= (tempids report)
                   {-1 101}))))

        (testing "upsert with tempid, order does not matter"
          (let [report (<? (dm/<transact! conn [[:db/add (dm/id-literal :db.part/user -1) :age 13]
                                                [:db/add (dm/id-literal :db.part/user -1) :name "Petr"]] now))]
            (is (= (<? (<shallow-entity (dm/db conn) 102))
                   {:name "Petr" :age 13 :email "@2"}))
            (is (= (tempids report)
                   {-1 102}))))

        (testing "Conflicting upserts fail"
          (is (thrown-with-msg? Throwable #"Conflicting upsert: #datomish.db.TempId\{:part :db.part/user, :idx -\d+\} resolves both to \d+ and \d+"
                                (<? (dm/<transact! conn [[:db/add (dm/id-literal :db.part/user -1) :name "Ivan"]
                                                         [:db/add (dm/id-literal :db.part/user -1) :age 35]
                                                         [:db/add (dm/id-literal :db.part/user -1) :name "Petr"]
                                                         [:db/add (dm/id-literal :db.part/user -1) :age 36]] now)))))
        (finally
          (<? (dm/close-db db)))))))


          conn (dm/connection-with-db db)
          now  0xdeadbeef]
      (try
        (let [tx0 (tx (<? (dm/<transact! conn test-schema now)))
              tx1 (tx (<? (dm/<transact! conn [[:db/add 1 :name "Ivan"]] now)))
              tx2 (tx (<? (dm/<transact! conn [[:db/add 1 :name "Petr"]] now)))
              tx3 (tx (<? (dm/<transact! conn [[:db/add 1 :aka "Tupen"]] now)))
              tx4 (tx (<? (dm/<transact! conn [[:db/add 1 :aka "Devil"]] now)))]
          (is (= (<? (<datoms-after (dm/db conn) tx0))
                 #{[1 :name "Petr"]
                   [1 :aka  "Tupen"]
                   [1 :aka  "Devil"]}))

          (is (= (<? (<transactions-after (dm/db conn) tx0))
                 [[1 :name "Ivan" tx1 1] ;; TODO: true, not 1.
                  [tx1 :db/txInstant now tx1 1]
                  [1 :name "Ivan" tx2 0]
