# \[dev-local\] Internal error in expound when having Datomic DB as a var in a failing spec

**URL:** <https://forum.datomic.com/t/dev-local-internal-error-in-expound-when-having-datomic-db-as-a-var-in-a-failing-spec/1688>\
**Category:** Troubleshooting\
**Created:** [November 13, 2020, 10:19am UTC](https://forum.datomic.com/t/dev-local-internal-error-in-expound-when-having-datomic-db-as-a-var-in-a-failing-spec/1688 "2020-11-13T10:19:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avocade](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/avocade/32/460_2.png) [@avocade](https://forum.datomic.com/u/avocade)\
**Post date:** [November 13, 2020, 10:19am UTC](https://forum.datomic.com/t/dev-local-internal-error-in-expound-when-having-datomic-db-as-a-var-in-a-failing-spec/1688/1 "2020-11-13T10:19:13Z")

</div>

In short the issue is that a datomic DB `(d/db conn)` looks like a regular `map?` to expound, which uses `postwalk` internally to traverse its values:

```clojure
(require '[datomic.client.api :as d])
(walk/postwalk identity [(d/db conn)])

```

This results in the error `java.lang.ClassCastException: class datomic.core.db.Datum cannot be cast to class java.lang.Number`. Took a while to troubleshoot this 😃 It’s now fixed by using Specter instead of `postwalk`.

The issue is reported here:

> <https://github.com/bhb/expound/issues/205>
>
> We've found an issue where lift-singleton-groups crashes when a datomic DB is one of the arguments. The crash is related to...

And a PR with a fix for this here:

> <https://github.com/bhb/expound/pull/206>

---

<div class="post-metadata">

**Author:** ![eneroth](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/eneroth/32/191_2.png) [@eneroth](https://forum.datomic.com/u/eneroth)\
**Post date:** [November 16, 2020, 6:41pm UTC](https://forum.datomic.com/t/dev-local-internal-error-in-expound-when-having-datomic-db-as-a-var-in-a-failing-spec/1688/2 "2020-11-16T18:41:52Z")

</div>

To further elaborate, we were surprised to see that,

```clojure
(map? (d/db conn))
;; => true

(keys (d/db conn))
;; => (:id :memidx :indexing :mid-index :index :history :basisT :nextEidx :indexBasisT :elements :keys :ids :index-root-id :index-rev :asOfT :sinceT :raw :filt :schema-level :birth-level :indexed-datoms :system-eids :t :as-of :since :history?)

```

And we have a feeling that this is tripping up `postwalk` and not allowing it to treat the DB as one unit, but attempting to break it down into parts, and reassemble it.

I.e., Expound is how we encountered this problem, but the problem is not with Expound itself. The same problem will appear wherever a DB appears in a data structure on which `postwalk` is applied.

---

<div class="post-metadata">

**Author:** ![eneroth](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.datomic.com/eneroth/32/191_2.png) [@eneroth](https://forum.datomic.com/u/eneroth)\
**Post date:** [February 6, 2021, 11:20am UTC](https://forum.datomic.com/t/dev-local-internal-error-in-expound-when-having-datomic-db-as-a-var-in-a-failing-spec/1688/3 "2021-02-06T11:20:32Z")

</div>

This problem keeps occurring when where walk is involved, most recently here: [Crash bug when printing, if a datomic db is present and the spec fails · Issue #209 · bhb/expound · GitHub](https://github.com/bhb/expound/issues/209)

I’m guessing that this has to do with `walk` trying to take the DB apart and put it back together again, probably yielding nonsense.
