Move RusqliteExecutor and SQLite functions to common crate#2486
Move RusqliteExecutor and SQLite functions to common crate#2486
Conversation
Relocate the executor and custom SQLite functions modules into crates/common/src/local_db so they can be reused outside the CLI. The CLI executor now re-exports from common. Also adds rusqlite with the functions feature as a regular dependency and switches the dev-dependency to tempfile.
Expose LocalDb and its constructor so external consumers can construct a LocalDb from a RusqliteExecutor. Add a non-wasm set_local_db method on RaindexClient for injecting the database.
WalkthroughMoved the Rusqlite-backed local DB executor into the common crate, re-exported it from the CLI, exposed LocalDb and a setter on RaindexClient for non‑WASM, added rusqlite/tempfile dependencies, and adjusted module exports and small comment removals. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/common/Cargo.toml`:
- Line 81: Replace the direct version pin "tempfile = \"3\"" with a workspace
reference to match other crates; change the dependency entry so it uses
tempfile.workspace = true (i.e., convert the current tempfile dependency line to
the workspace-style declaration) to centralize version management and ensure
consistency with the CLI crate's tempfile.workspace = true usage.
ℹ️ Review info
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
crates/cli/Cargo.tomlcrates/common/Cargo.toml
| httpmock = "0.7.0" | ||
| rain_orderbook_test_fixtures = { workspace = true } | ||
| rusqlite = "0.31.0" | ||
| tempfile = "3" |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Use workspace reference for tempfile dependency.
The CLI crate uses tempfile.workspace = true (line 53 in crates/cli/Cargo.toml), but here a direct version is specified. For consistency and centralized version management, use the workspace reference.
♻️ Proposed fix
-tempfile = "3"
+tempfile = { workspace = true }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| tempfile = "3" | |
| tempfile = { workspace = true } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/common/Cargo.toml` at line 81, Replace the direct version pin
"tempfile = \"3\"" with a workspace reference to match other crates; change the
dependency entry so it uses tempfile.workspace = true (i.e., convert the current
tempfile dependency line to the workspace-style declaration) to centralize
version management and ensure consistency with the CLI crate's
tempfile.workspace = true usage.
Motivation
The
RusqliteExecutorand custom SQLite functions (float_is_zero,float_negate,float_sum,float_zero_hex) were previously confined to the CLI crate, making them inaccessible to other consumers in the workspace. Moving them to the common crate enables reuse across crates that need direct SQLite access with custom functions.Solution
RusqliteExecutorand all custom SQLite function modules fromcrates/cli/src/commands/local_db/tocrates/common/src/local_db/.RusqliteExecutorfrom common, preserving backwards compatibility.rusqlite(withfunctionsfeature) as a regular dependency in common; switchedrusqlitedev-dependency totempfile.LocalDband its constructor public so external consumers can construct aLocalDbfrom aRusqliteExecutor.set_local_dbmethod onRaindexClientfor injecting the database at runtime.#[cfg(not(target_family = "wasm"))].Checks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
New Features
Refactor
Chores