Skip to content

Replace exqlite with esqlite#3933

Merged
magnetised merged 2 commits intomainfrom
magnetised/esqlite-sqlite-driver
Mar 4, 2026
Merged

Replace exqlite with esqlite#3933
magnetised merged 2 commits intomainfrom
magnetised/esqlite-sqlite-driver

Conversation

@magnetised
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.77%. Comparing base (d63e3f5) to head (7a78463).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3933   +/-   ##
=======================================
  Coverage   88.77%   88.77%           
=======================================
  Files          25       25           
  Lines        2415     2415           
  Branches      611      606    -5     
=======================================
  Hits         2144     2144           
  Misses        269      269           
  Partials        2        2           
Flag Coverage Δ
packages/experimental 87.73% <ø> (ø)
packages/react-hooks 86.48% <ø> (ø)
packages/start 82.83% <ø> (ø)
packages/typescript-client 94.01% <ø> (ø)
packages/y-electric 56.05% <ø> (ø)
typescript 88.77% <ø> (ø)
unit-tests 88.77% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@magnetised magnetised force-pushed the magnetised/esqlite-sqlite-driver branch 3 times, most recently from 3eaee4e to 7883961 Compare March 4, 2026 09:48
@magnetised magnetised marked this pull request as ready for review March 4, 2026 09:49
@blacksmith-sh

This comment has been minimized.

Copy link
Member

@alco alco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of edge cases to consider:

URI encoding may not handle all paths (sqlite3.ex:193)

"file:#{URI.encode(path)}?mode=#{mode}"

URI.encode/1 may not correctly escape all SQLite URI special characters. Paths containing #, ?, or % could cause issues since these have special meaning in URIs. Consider using URI.encode(path, &URI.char_unreserved?/1) or similar to ensure all problematic characters are escaped.

convert_bind/1 may be incomplete (sqlite3.ex:202-206)

defp convert_bind(nil), do: :undefined
defp convert_bind(:null), do: :undefined
defp convert_bind(value), do: value

This passes through most values unchanged. Does esqlite handle all the same types that exqlite did (booleans, atoms, DateTime, etc.)? May need additional conversions if exqlite was doing implicit type coercion that esqlite doesn't.

Copy link
Member

@alco alco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude erased my previous pending comments that I had meant to post, so here they are.

| close(conn) | close(conn) |
| execute(conn, sql) | exec(conn, sql) |
| prepare(conn, sql) | prepare(conn, sql) |
| release(conn, stmt) | no-op – GC'd by esqlite |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At what point does it get GC'd? Better document this?

| prepare(conn, sql) | prepare(conn, sql) |
| release(conn, stmt) | no-op – GC'd by esqlite |
| bind(stmt, binds) | bind(stmt, binds) |
| step(conn, stmt) | step(stmt) – conn arg dropped |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the conn state held for this with esqlite3? Process dict or the statement itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the step/2 function? Everything's in the nif resource.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, for step. I'm unsure what the NIF resource is tied to in BEAM: is its lifetime tied to the process where the connection is open?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a (dense) para that explains how prepared statements are tied to the process memory - I asked the same questions re the lack of release for the stmts and was satisfied by the answer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That helps.

I'm not too familiar with NIF resource lifetime management and how that plays with Erlang's GC. Like, if a process dies and its whole heap can be released, does the GC still scan it looking for NIF resources that need to be destroyed? It's not related to your changes, just mind-wandering.

@blacksmith-sh

This comment has been minimized.

@magnetised magnetised force-pushed the magnetised/esqlite-sqlite-driver branch from a60c7b6 to 7a78463 Compare March 4, 2026 11:53
@magnetised magnetised requested a review from alco March 4, 2026 11:59
Copy link
Member

@alco alco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@magnetised magnetised merged commit 4608e2e into main Mar 4, 2026
73 of 79 checks passed
@magnetised magnetised deleted the magnetised/esqlite-sqlite-driver branch March 4, 2026 12:12
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

This PR has been released! 🚀

The following packages include changes from this PR:

  • @core/sync-service@1.4.12

Thanks for contributing to Electric!

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.

2 participants