Skip to content

fix(query): replace Marshal.to_string dedup keys with typed hash tables - #44

Merged
tiensonqin merged 1 commit into
mainfrom
fix/marshal-melange
Oct 11, 2026
Merged

tiensonqin merged 1 commit into
mainfrom
fix/marshal-melange

Conversation

@tiensonqin

Copy link
Copy Markdown
Contributor

Summary

Marshal.* externals are not polyfilled by Melange, so every q call threw at runtime in JS bundles (caml_output_value_to_string not polyfilled by Melange yet). This broke logseq/logseq CI on devin/ocaml-db-worker (CLI E2E graph-export-edn-options-partial, ocaml-e2e datascript_query editor case).

Replace the four marshaled-key hash tables in impl/datascript.ml with typed Hashtbl.Make tables exported by impl/query_api.ml:

  • Query_value_table — value keys (compare_query_value / query_value_hash)
  • Query_result_table — query_result keys (compare_query_result / query_result_hash)
  • existing List_row_table — query_result list row keys

Same dedup semantics (first occurrence wins), faster than marshal + structural string compare, and Melange-safe since it uses no native-only externals.

Verified: all 29 native test executables pass on this branch.

Link to Devin session: https://app.devin.ai/sessions/39cf217367ca4dd388a4828e90a301c2
Open in Devin Desktop: https://app.devin.ai/desktop/session/39cf217367ca4dd388a4828e90a301c2?variant=devin
Requested by: @tiensonqin

Marshal.* externals are not polyfilled by Melange, so every q call
crashed when compiled to JS (logseq/logseq CI). Use the existing typed
Hashtbl.Make tables in query_api.ml (query_value_hash, query_result_hash,
query_result list) instead of marshaled string keys — same dedup
semantics, faster, and Melange-safe.
@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@tiensonqin
tiensonqin merged commit 7acb4e8 into main Oct 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant