-
Notifications
You must be signed in to change notification settings - Fork 0
Add FLOAT_NEGATE
function
#11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughIntroduces a new SQLite scalar function FLOAT_NEGATE backed by Rust, registers it in the core module, and adds comprehensive tests. Updates float-sum tests to use shared fixtures. Adds shared test utilities for float hex handling. Bumps a local dependency tarball reference. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant SQLite
participant "float_negate (C ABI)" as ABI
participant "float_negate_hex_to_hex" as Helper
participant "Float lib" as Float
Client->>SQLite: SELECT FLOAT_NEGATE(arg)
SQLite->>ABI: Invoke xFunc (argc=1, argv[0])
alt arg is NULL
ABI-->>SQLite: return NULL
else arg is text
ABI->>Helper: negate hex string
Helper->>Float: from_hex(input)
Float-->>Helper: Float value
Helper->>Float: negate (unary -)
Helper->>Float: as_hex()
Float-->>Helper: "0x...hex"
Helper-->>ABI: negated hex
ABI-->>SQLite: result text
else invalid input
ABI-->>SQLite: SQLITE error with message
end
SQLite-->>Client: result/error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro ⛔ Files ignored due to path filters (2)
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)svelte-test/package.json📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧠 Learnings (3)📓 Common learnings
📚 Learning: 2025-09-17T06:55:20.178Z
Applied to files:
📚 Learning: 2025-08-27T05:59:04.254Z
Applied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Comment |
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
svelte-test/tests/database-functions/float-sum.test.ts (2)
48-55
: Fix schema: NOT NULL blocks your NULL‑handling tests.The table defines
amount TEXT NOT NULL
but later insertsNULL
, causing INSERT failures (previously noted in learnings). Makeamount
nullable for this test table.Apply this diff:
- CREATE TABLE float_test ( + CREATE TABLE float_test ( id INTEGER PRIMARY KEY AUTOINCREMENT, - amount TEXT NOT NULL, + amount TEXT, category TEXT, description TEXT )
547-561
: Make float_test.amount nullable — NULL-handling tests insert NULL and currently violate NOT NULLsvelte-test/tests/database-functions/float-sum.test.ts: CREATE TABLE float_test defines
amount TEXT NOT NULL
(around lines 48–50); change toamount TEXT
(remove NOT NULL) and re-run the NULL Value Handling block:
pnpm vitest run svelte-test/tests/database-functions/float-sum.test.ts -t "NULL Value Handling"packages/sqlite-web-core/src/database_functions/float_negate.rs (1)
66-120
: Add a test for hex without the 0x prefix (parity with FLOAT_SUM).FLOAT_SUM accepts no‑prefix hex; FLOAT_NEGATE should, too. Add a positive test to lock this in.
Apply this diff:
@@ fn test_float_negate_hex_to_hex_high_precision() { @@ } + #[wasm_bindgen_test] + fn test_float_negate_hex_to_hex_without_prefix() { + let pos_hex = Float::parse("42.125".to_string()).unwrap().as_hex(); + let no_prefix = pos_hex.trim_start_matches("0x"); + let expected = Float::parse("-42.125".to_string()).unwrap().as_hex(); + let out = float_negate_hex_to_hex(no_prefix).unwrap(); + assert_eq!(out, expected); + } + #[wasm_bindgen_test] fn test_float_negate_hex_to_hex_whitespace() {
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (6)
packages/sqlite-web-core/src/database_functions/float_negate.rs
(1 hunks)packages/sqlite-web-core/src/database_functions/float_sum.rs
(2 hunks)packages/sqlite-web-core/src/database_functions/mod.rs
(2 hunks)svelte-test/tests/database-functions/float-negate.test.ts
(1 hunks)svelte-test/tests/database-functions/float-sum.test.ts
(2 hunks)svelte-test/tests/fixtures/float-utils.ts
(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.165Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.039Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
📚 Learning: 2025-09-17T08:04:44.039Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.039Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
packages/sqlite-web-core/src/database_functions/float_sum.rs
svelte-test/tests/database-functions/float-sum.test.ts
📚 Learning: 2025-09-17T06:55:20.165Z
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.165Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
packages/sqlite-web-core/src/database_functions/float_sum.rs
packages/sqlite-web-core/src/database_functions/mod.rs
packages/sqlite-web-core/src/database_functions/float_negate.rs
svelte-test/tests/database-functions/float-sum.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test
- GitHub Check: test
🔇 Additional comments (6)
packages/sqlite-web-core/src/database_functions/float_sum.rs (2)
189-201
: Good move: derive hex from Float in tests (less brittle).Generating hex via
Float::parse(...).as_hex()
avoids stale literals and keeps tests aligned with the lib’s encoding. Looks good.
210-221
: Uppercase 0X rejection covered well.Building the inputs dynamically via
replacen("0x","0X",1)
keeps this negative case future‑proof.svelte-test/tests/fixtures/float-utils.ts (2)
5-11
: Solid error wrapping and typed helpers.Clear surfacing of parse/fromHex/format failures and strong typing on hex inputs/outputs. LGTM.
Also applies to: 20-31
37-48
: Mixed‑case generator behaves as intended.Alternating case only on a–f preserves the
0x
prefix and exercises parser tolerance. Good utility.packages/sqlite-web-core/src/database_functions/mod.rs (1)
11-11
: Module wiring for FLOAT_NEGATE looks correct.
mod float_negate;
anduse float_negate::*;
are in the right place relative to other registrations.Also applies to: 16-16
packages/sqlite-web-core/src/database_functions/float_negate.rs (1)
20-64
: FFI wrapper is correct and memory‑safe under SQLITE_TRANSIENT.Argument validation, NULL propagation, CString handling, and result wiring look good.
Please confirm that
Float::from_hex
intentionally accepts inputs without the0x
prefix (parity with FLOAT_SUM). If so, consider documenting this in the function comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
♻️ Duplicate comments (4)
packages/sqlite-web-core/src/database_functions/float_negate.rs (1)
8-10
: Empty-input error handling aligned with FLOAT_SUM (good).Explicit trim + empty check matches prior guidance and keeps UX consistent.
svelte-test/tests/database-functions/float-negate.test.ts (2)
8-13
: Extension-less import is fine per repo conventions.Acknowledging maintainer’s preference; no action needed.
141-146
: Assert success before NULL parsing.Make the failure mode explicit.
it("should return NULL when input is NULL", async () => { - const res = await db.query("SELECT FLOAT_NEGATE(NULL) as neg"); + const res = await db.query("SELECT FLOAT_NEGATE(NULL) as neg"); + expect(res.error).toBeFalsy(); const data = JSON.parse(res.value || "[]"); expect(data[0].neg).toBeNull(); });packages/sqlite-web-core/src/database_functions/mod.rs (1)
83-101
: Good: registered as deterministic and innocuous; improve diagnostics on failure.Include rc and sqlite3_errmsg(db) to speed up triage when registration fails.
- if ret != SQLITE_OK { - return Err("Failed to register FLOAT_NEGATE function".to_string()); - } + if ret != SQLITE_OK { + let msg = unsafe { CStr::from_ptr(sqlite3_errmsg(db)) } + .to_string_lossy() + .into_owned(); + return Err(format!("Failed to register FLOAT_NEGATE (rc={ret}): {msg}")); + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
svelte-test/tests/database-functions/__screenshots__/float-negate.test.ts/FLOAT-NEGATE-Database-Function-Function-Availability-should-have-FLOAT-NEGATE-function-available-1.png
is excluded by!**/*.png
📒 Files selected for processing (3)
packages/sqlite-web-core/src/database_functions/float_negate.rs
(1 hunks)packages/sqlite-web-core/src/database_functions/mod.rs
(2 hunks)svelte-test/tests/database-functions/float-negate.test.ts
(1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.165Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:64-72
Timestamp: 2025-09-17T17:09:58.729Z
Learning: FLOAT_SUM functionality is available and working in the codebase, so tests can rely on it without needing availability checks or gating logic.
📚 Learning: 2025-09-17T06:55:20.165Z
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.165Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Applied to files:
packages/sqlite-web-core/src/database_functions/float_negate.rs
svelte-test/tests/database-functions/float-negate.test.ts
packages/sqlite-web-core/src/database_functions/mod.rs
📚 Learning: 2025-09-17T08:04:44.039Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.039Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
📚 Learning: 2025-09-17T17:17:41.817Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.817Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies [a-f] characters, preserving the 'x' in '0x' prefixes, so it won't create conflicts with tests that reject '0X' prefixes.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
📚 Learning: 2025-09-17T17:17:41.817Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.817Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies characters matching /[a-f]/ (hex digits a-f), preserving the 'x' in '0x' prefixes and all other characters unchanged, so it won't create conflicts with tests that reject '0X' prefixes.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
📚 Learning: 2025-09-17T17:09:58.729Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:64-72
Timestamp: 2025-09-17T17:09:58.729Z
Learning: FLOAT_SUM functionality is available and working in the codebase, so tests can rely on it without needing availability checks or gating logic.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
📚 Learning: 2025-08-27T05:59:04.254Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#5
File: svelte-test/tests/database-functions/bigint-sum.test.ts:2-7
Timestamp: 2025-08-27T05:59:04.254Z
Learning: In the sqlite-web repository, the user prefers to keep .js extensions when importing TypeScript files in test files, even in Vitest environments. This is acceptable and should not be flagged as an issue.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
🧬 Code graph analysis (3)
packages/sqlite-web-core/src/database_functions/float_negate.rs (1)
packages/sqlite-web-core/src/database_functions/float_sum.rs (4)
std
(65-65)std
(82-82)std
(109-112)std
(142-145)
svelte-test/tests/database-functions/float-negate.test.ts (2)
svelte-test/tests/fixtures/float-utils.ts (4)
createFloatHexMap
(50-56)withoutPrefix
(33-35)decodeFloatHex
(20-31)toMixedCase
(37-48)svelte-test/tests/fixtures/test-helpers.ts (3)
PerformanceTracker
(138-168)createTestDatabase
(6-22)cleanupDatabase
(173-201)
packages/sqlite-web-core/src/database_functions/mod.rs (1)
packages/sqlite-web-core/src/database_functions/float_negate.rs (2)
float_negate
(24-68)std
(54-57)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test
- GitHub Check: test
🔇 Additional comments (6)
packages/sqlite-web-core/src/database_functions/float_negate.rs (4)
12-21
: Parse → negate → as_hex flow is correct and lossless.Straight-through mapping with precise errors; no precision round-trips.
24-36
: Argument count guard is correct; message is clear.Early return avoids undefined argv reads.
118-122
: Nice coverage for invalid inputs.Catches 0X, empty, and non-hex; mirrors runtime behavior well.
8-10
: Confirmed: error-string matches FLOAT_SUMExact literal found in float_sum.rs:18 and float_negate.rs:9 — "Empty string is not a valid hex number".
packages/sqlite-web-core/src/database_functions/mod.rs (1)
11-17
: Module wiring looks correct.Re-exports and use statements are coherent; no leakage beyond intended surface.
svelte-test/tests/database-functions/float-negate.test.ts (1)
103-118
: Mixed‑case test is valid; prefix remains ‘0x’.toMixedCase preserves the ‘x’, so this won’t collide with the explicit 0X‑rejection test.
packages/sqlite-web-core/src/database_functions/float_negate.rs
Outdated
Show resolved
Hide resolved
if let Ok(result_cstr) = CString::new(result_hex) { | ||
sqlite3_result_text( | ||
context, | ||
result_cstr.as_ptr(), | ||
result_cstr.as_bytes().len() as c_int, | ||
Some(std::mem::transmute::< | ||
isize, | ||
unsafe extern "C" fn(*mut std::ffi::c_void), | ||
>(-1isize)), // SQLITE_TRANSIENT | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick
Correct use of SQLITE_TRANSIENT.
Casting -1 to destructor matches pattern used elsewhere (FLOAT_SUM) and avoids lifetime issues.
You could centralize this as a const to reduce repetition:
const SQLITE_TRANSIENT: unsafe extern "C" fn(*mut std::ffi::c_void) =
unsafe { std::mem::transmute::<isize, _>(-1) };
🤖 Prompt for AI Agents
In packages/sqlite-web-core/src/database_functions/float_negate.rs around lines
49 to 58, the call to sqlite3_result_text currently transmutes -1isize inline to
produce the SQLITE_TRANSIENT destructor; replace the inline transmute with a
shared const binding for SQLITE_TRANSIENT (typed as unsafe extern "C" fn(*mut
std::ffi::c_void)) defined near the top of the module and use that const in
sqlite3_result_text to avoid repeated unsafe transmute usage and clarify intent.
packages/sqlite-web-core/src/database_functions/float_negate.rs
Outdated
Show resolved
Hide resolved
#[wasm_bindgen_test] | ||
fn test_float_negate_hex_to_hex_zero() { | ||
let zero_hex = Float::parse("0".to_string()).unwrap().as_hex(); | ||
let expected_zero_hex = Float::parse("0".to_string()).unwrap().as_hex(); | ||
let out = float_negate_hex_to_hex(&zero_hex).unwrap(); | ||
assert_eq!(out, expected_zero_hex); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick
Add a test for signed zero behavior.
If Float distinguishes -0 and 0, assert expected normalization.
fn test_float_negate_hex_to_hex_zero() {
let zero_hex = Float::parse("0".to_string()).unwrap().as_hex();
let expected_zero_hex = Float::parse("0".to_string()).unwrap().as_hex();
let out = float_negate_hex_to_hex(&zero_hex).unwrap();
assert_eq!(out, expected_zero_hex);
}
+ #[wasm_bindgen_test]
+ fn test_float_negate_hex_to_hex_negative_zero() {
+ let neg_zero_hex = Float::parse("-0".to_string()).unwrap().as_hex();
+ let out = float_negate_hex_to_hex(&neg_zero_hex).unwrap();
+ // Expect normalization to +0; adjust if library preserves -0
+ let zero_hex = Float::parse("0".to_string()).unwrap().as_hex();
+ assert_eq!(out, zero_hex);
+ }
📝 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.
#[wasm_bindgen_test] | |
fn test_float_negate_hex_to_hex_zero() { | |
let zero_hex = Float::parse("0".to_string()).unwrap().as_hex(); | |
let expected_zero_hex = Float::parse("0".to_string()).unwrap().as_hex(); | |
let out = float_negate_hex_to_hex(&zero_hex).unwrap(); | |
assert_eq!(out, expected_zero_hex); | |
} | |
#[wasm_bindgen_test] | |
fn test_float_negate_hex_to_hex_zero() { | |
let zero_hex = Float::parse("0".to_string()).unwrap().as_hex(); | |
let expected_zero_hex = Float::parse("0".to_string()).unwrap().as_hex(); | |
let out = float_negate_hex_to_hex(&zero_hex).unwrap(); | |
assert_eq!(out, expected_zero_hex); | |
} | |
#[wasm_bindgen_test] | |
fn test_float_negate_hex_to_hex_negative_zero() { | |
let neg_zero_hex = Float::parse("-0".to_string()).unwrap().as_hex(); | |
let out = float_negate_hex_to_hex(&neg_zero_hex).unwrap(); | |
// Expect normalization to +0; adjust if library preserves -0 | |
let zero_hex = Float::parse("0".to_string()).unwrap().as_hex(); | |
assert_eq!(out, zero_hex); | |
} |
🤖 Prompt for AI Agents
In packages/sqlite-web-core/src/database_functions/float_negate.rs around lines
91 to 97, add a test covering signed zero: parse "-0" and "0" to hex, call
float_negate_hex_to_hex on each, and assert the output matches the expected
normalized representation (decide whether negating -0 yields "0" or "-0" based
on Float's normalization and assert that explicitly); ensure the test verifies
both parsing and negation round-trips so signed-zero behavior is asserted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to test this out. out of scope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findolor Understood! No problem at all - I'll skip this test suggestion since it's out of scope for this PR. The current test coverage looks good for the main functionality.
🧠 Learnings used
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.165Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.817Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies characters matching /[a-f]/ (hex digits a-f), preserving the 'x' in '0x' prefixes and all other characters unchanged, so it won't create conflicts with tests that reject '0X' prefixes.
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.817Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies [a-f] characters, preserving the 'x' in '0x' prefixes, so it won't create conflicts with tests that reject '0X' prefixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Float doesn't distinguish between -0 and 0 as far as I remember
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
try { | ||
const pragmaResult = await db.query("PRAGMA function_list"); | ||
const functions = JSON.parse(pragmaResult.value || "[]"); | ||
const entry = functions.find((f: any) => f.name === "FLOAT_NEGATE"); | ||
expect(entry).toBeDefined(); | ||
} catch (e) {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick
Don’t swallow PRAGMA errors.
Fail fast or assert success to make availability issues actionable.
- try {
- const pragmaResult = await db.query("PRAGMA function_list");
- const functions = JSON.parse(pragmaResult.value || "[]");
- const entry = functions.find((f: any) => f.name === "FLOAT_NEGATE");
- expect(entry).toBeDefined();
- } catch (e) {}
+ const pragmaResult = await db.query("PRAGMA function_list");
+ expect(pragmaResult.error).toBeFalsy();
+ const functions = JSON.parse(pragmaResult.value || "[]");
+ const entry = functions.find((f: any) => f.name === "FLOAT_NEGATE");
+ expect(entry).toBeDefined();
📝 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.
try { | |
const pragmaResult = await db.query("PRAGMA function_list"); | |
const functions = JSON.parse(pragmaResult.value || "[]"); | |
const entry = functions.find((f: any) => f.name === "FLOAT_NEGATE"); | |
expect(entry).toBeDefined(); | |
} catch (e) {} | |
const pragmaResult = await db.query("PRAGMA function_list"); | |
expect(pragmaResult.error).toBeFalsy(); | |
const functions = JSON.parse(pragmaResult.value || "[]"); | |
const entry = functions.find((f: any) => f.name === "FLOAT_NEGATE"); | |
expect(entry).toBeDefined(); |
🤖 Prompt for AI Agents
In svelte-test/tests/database-functions/float-negate.test.ts around lines 39 to
45, the try/catch block currently swallows any error from the PRAGMA query which
hides failures; remove the empty catch and instead let the error propagate or
explicitly fail the test (e.g., await the db.query without a catch or catch and
rethrow/assert with expect.fail or throw new Error) so PRAGMA errors cause the
test to fail and include the error message; also assert that pragmaResult.value
is defined before JSON.parse to avoid masking parse errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findolor Understood, I'll respect your decision to keep the current error handling approach in the test.
(\ /)
( ._.)
o_(")(")
🧠 Learnings used
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.039Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.165Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:64-72
Timestamp: 2025-09-17T17:09:58.729Z
Learning: FLOAT_SUM functionality is available and working in the codebase, so tests can rely on it without needing availability checks or gating logic.
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.817Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies [a-f] characters, preserving the 'x' in '0x' prefixes, so it won't create conflicts with tests that reject '0X' prefixes.
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.817Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies characters matching /[a-f]/ (hex digits a-f), preserving the 'x' in '0x' prefixes and all other characters unchanged, so it won't create conflicts with tests that reject '0X' prefixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
svelte-test/tests/database-functions/float-negate.test.ts (1)
36-41
: Swallowed PRAGMA errors (not re‑raising).This was discussed earlier and accepted; leaving as‑is.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
packages/sqlite-web-core/src/database_functions/float_negate.rs
(1 hunks)svelte-test/tests/database-functions/float-negate.test.ts
(1 hunks)
🧰 Additional context used
🧠 Learnings (9)
📓 Common learnings
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.178Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
📚 Learning: 2025-09-17T08:04:44.062Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.062Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-09-17T17:17:41.827Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.827Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies [a-f] characters, preserving the 'x' in '0x' prefixes, so it won't create conflicts with tests that reject '0X' prefixes.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-09-17T17:17:41.827Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.827Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies characters matching /[a-f]/ (hex digits a-f), preserving the 'x' in '0x' prefixes and all other characters unchanged, so it won't create conflicts with tests that reject '0X' prefixes.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-09-17T17:09:58.740Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:64-72
Timestamp: 2025-09-17T17:09:58.740Z
Learning: FLOAT_SUM functionality is available and working in the codebase, so tests can rely on it without needing availability checks or gating logic.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
📚 Learning: 2025-08-27T05:59:04.254Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#5
File: svelte-test/tests/database-functions/bigint-sum.test.ts:2-7
Timestamp: 2025-08-27T05:59:04.254Z
Learning: In the sqlite-web repository, the user prefers to keep .js extensions when importing TypeScript files in test files, even in Vitest environments. This is acceptable and should not be flagged as an issue.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
📚 Learning: 2025-09-17T06:55:20.178Z
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.178Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-08-27T05:55:40.481Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#5
File: packages/sqlite-web-core/src/database_functions/bigint_sum.rs:76-93
Timestamp: 2025-08-27T05:55:40.481Z
Learning: In the sqlite-web-core codebase, for SQLite aggregate function context initialization, the maintainer prefers using byte-scanning to detect zero-initialized memory rather than using explicit initialization flags or Option wrappers.
Applied to files:
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-09-15T06:11:31.781Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#9
File: packages/sqlite-web-core/src/coordination.rs:52-65
Timestamp: 2025-09-15T06:11:31.781Z
Learning: In packages/sqlite-web-core/src/coordination.rs, the pattern of using `db.borrow_mut().take()` followed by async database operations and then putting the database back with `*db.borrow_mut() = Some(database)` is safe in their use case and doesn't cause concurrent access issues or "Database not initialized" errors.
Applied to files:
packages/sqlite-web-core/src/database_functions/float_negate.rs
🧬 Code graph analysis (1)
svelte-test/tests/database-functions/float-negate.test.ts (2)
svelte-test/tests/fixtures/float-utils.ts (4)
createFloatHexMap
(50-56)withoutPrefix
(33-35)decodeFloatHex
(20-31)toMixedCase
(37-48)svelte-test/tests/fixtures/test-helpers.ts (2)
createTestDatabase
(6-22)cleanupDatabase
(173-201)
🔇 Additional comments (10)
packages/sqlite-web-core/src/database_functions/float_negate.rs (4)
5-21
: Helper logic is correct and precise.Trim + explicit empty-input check + hex parse + negation + as_hex round‑trip looks solid and consistent with other Float functions.
45-52
: Good strict UTF‑8 handling.Switch to CStr::to_str() with a clear error is the right trade‑off for TEXT args.
67-79
: Error propagation path is robust.CString guarding interior NULs and falling back to a fixed message is correct.
56-63
: Ensure SQLITE_TRANSIENT() is the special “copy” destructor (-1) and is defined once with the correct destructor function-pointer type.packages/sqlite-web-core/src/database_functions/float_negate.rs (lines 56–63) calls sqlite3_result_text(..., SQLITE_TRANSIENT()); no SQLITE_TRANSIENT definition was found in the repository — add or reference a single, correctly‑typed SQLITE_TRANSIENT (the -1 cast matching sqlite3_result_text's destructor type) to avoid SQLite reading freed memory.
svelte-test/tests/database-functions/float-negate.test.ts (6)
14-21
: Fixture generation looks good.createFloatHexMap centralizes inputs; keeps tests readable and consistent.
64-80
: Zero‑sum property test is spot‑on.Covers prefixed/unprefixed/hi‑precision/zero and asserts via FLOAT_SUM.
82-99
: Whitespace handling test is appropriate.Validates trim behavior end‑to‑end.
100-115
: Mixed‑case acceptance is valid.toMixedCase only touches [a‑f], preserving the 'x' in '0x' as intended.
117-135
: Involution test (double negate) is a good addition.Covers positive, negative, zero cases by string equality.
145-164
: Error‑path assertions look correct.Covers 0X prefix, non‑hex, and empty string with expected messages.
packages/sqlite-web-core/src/database_functions/float_negate.rs
Outdated
Show resolved
Hide resolved
it("should return NULL when input is NULL", async () => { | ||
const res = await db.query("SELECT FLOAT_NEGATE(NULL) as neg"); | ||
const data = JSON.parse(res.value || "[]"); | ||
expect(data[0].neg).toBeNull(); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick
Assert success before parsing NULL case.
Small clarity win: check res.error is falsy before JSON.parse.
Apply this diff:
it("should return NULL when input is NULL", async () => {
- const res = await db.query("SELECT FLOAT_NEGATE(NULL) as neg");
+ const res = await db.query("SELECT FLOAT_NEGATE(NULL) as neg");
+ expect(res.error).toBeFalsy();
const data = JSON.parse(res.value || "[]");
expect(data[0].neg).toBeNull();
});
📝 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.
it("should return NULL when input is NULL", async () => { | |
const res = await db.query("SELECT FLOAT_NEGATE(NULL) as neg"); | |
const data = JSON.parse(res.value || "[]"); | |
expect(data[0].neg).toBeNull(); | |
}); | |
it("should return NULL when input is NULL", async () => { | |
const res = await db.query("SELECT FLOAT_NEGATE(NULL) as neg"); | |
expect(res.error).toBeFalsy(); | |
const data = JSON.parse(res.value || "[]"); | |
expect(data[0].neg).toBeNull(); | |
}); |
🤖 Prompt for AI Agents
In svelte-test/tests/database-functions/float-negate.test.ts around lines 139 to
144, the test parses res.value without first asserting the query succeeded; add
an assertion that res.error is falsy (e.g., expect(res.error).toBeFalsy() or
equivalent) immediately after the query and before JSON.parse so the test fails
clearly on query errors instead of throwing during parse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findolor, understood. I'll skip that error check suggestion since you've indicated it's not necessary for this test case.
🧠 Learnings used
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.062Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.827Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies [a-f] characters, preserving the 'x' in '0x' prefixes, so it won't create conflicts with tests that reject '0X' prefixes.
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.827Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies characters matching /[a-f]/ (hex digits a-f), preserving the 'x' in '0x' prefixes and all other characters unchanged, so it won't create conflicts with tests that reject '0X' prefixes.
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.178Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (1)
packages/sqlite-web-core/src/database_functions/float_negate.rs (1)
38-46
: Minor: Reusearg0
to avoid double deref and make intent explicitKeeps consistency with the comment and avoids repeating
*argv
.- if sqlite3_value_type(*argv) == SQLITE_NULL { + let arg0 = *argv; + if sqlite3_value_type(arg0) == SQLITE_NULL { sqlite3_result_null(context); return; } - // Get the text value (now known to be non-NULL). - let value_ptr = sqlite3_value_text(*argv); + // Get the text value (now known to be non-NULL). + let value_ptr = sqlite3_value_text(arg0);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
svelte-test/package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (1)
packages/sqlite-web-core/src/database_functions/float_negate.rs
(1 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.178Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.062Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
📚 Learning: 2025-09-17T06:55:20.178Z
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.178Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Applied to files:
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-08-27T05:55:40.481Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#5
File: packages/sqlite-web-core/src/database_functions/bigint_sum.rs:76-93
Timestamp: 2025-08-27T05:55:40.481Z
Learning: In the sqlite-web-core codebase, for SQLite aggregate function context initialization, the maintainer prefers using byte-scanning to detect zero-initialized memory rather than using explicit initialization flags or Option wrappers.
Applied to files:
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-09-15T06:11:31.781Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#9
File: packages/sqlite-web-core/src/coordination.rs:52-65
Timestamp: 2025-09-15T06:11:31.781Z
Learning: In packages/sqlite-web-core/src/coordination.rs, the pattern of using `db.borrow_mut().take()` followed by async database operations and then putting the database back with `*db.borrow_mut() = Some(database)` is safe in their use case and doesn't cause concurrent access issues or "Database not initialized" errors.
Applied to files:
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-09-17T17:17:41.827Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.827Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies characters matching /[a-f]/ (hex digits a-f), preserving the 'x' in '0x' prefixes and all other characters unchanged, so it won't create conflicts with tests that reject '0X' prefixes.
Applied to files:
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-09-17T17:17:41.827Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.827Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies [a-f] characters, preserving the 'x' in '0x' prefixes, so it won't create conflicts with tests that reject '0X' prefixes.
Applied to files:
packages/sqlite-web-core/src/database_functions/float_negate.rs
📚 Learning: 2025-09-17T08:04:44.062Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.062Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
Applied to files:
packages/sqlite-web-core/src/database_functions/float_negate.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test
- GitHub Check: test
🔇 Additional comments (5)
packages/sqlite-web-core/src/database_functions/float_negate.rs (5)
8-15
: Empty-input handling and parse errors look goodTrim + explicit empty check and clear parse errors match prior functions.
47-54
: Strict UTF‑8 validation: LGTMCorrect to fail fast on invalid UTF‑8 rather than lossy conversion.
58-65
: Correct use ofsqlite3_result_text
withSQLITE_TRANSIENT
Passing explicit length and transient destructor is safe; ownership/lifetime is correct.
69-80
: Robust error propagation pathGood handling of interior NULs and consistent messaging.
84-137
: Unit tests cover key pathsCovers sign flip, zero, precision, whitespace, and invalids. Looks solid.
#[wasm_bindgen_test] | ||
fn test_float_negate_hex_to_hex_zero() { | ||
let zero_hex = Float::parse("0".to_string()).unwrap().as_hex(); | ||
let expected_zero_hex = Float::parse("0".to_string()).unwrap().as_hex(); | ||
let out = float_negate_hex_to_hex(&zero_hex).unwrap(); | ||
assert_eq!(out, expected_zero_hex); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Float doesn't distinguish between -0 and 0 as far as I remember
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
svelte-test/tests/database-functions/float-sum.test.ts (1)
47-53
: Fix NOT NULL schema: NULL-handling tests currently violate the constraint.Later tests insert NULL into amount; with TEXT NOT NULL the INSERT fails and can mask assertions.
Apply this diff to allow NULLs:
- amount TEXT NOT NULL, + amount TEXT,Alternatively, create a separate nullable table just within the “NULL Value Handling” describe.
♻️ Duplicate comments (3)
svelte-test/tests/database-functions/float-sum.test.ts (1)
8-14
: Extension-less fixture import is acceptable in this repo.Prior discussion established this works in your setup; leaving as-is.
svelte-test/tests/database-functions/float-negate.test.ts (2)
7-12
: Extension-less fixture import acknowledged.Consistent with earlier decision; no change needed.
139-144
: Optional: assert success before parse.Tiny clarity win; add an error check prior to JSON.parse.
- const res = await db.query("SELECT FLOAT_NEGATE(NULL) as neg"); + const res = await db.query("SELECT FLOAT_NEGATE(NULL) as neg"); + expect(res.error).toBeFalsy(); const data = JSON.parse(res.value || "[]");
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (2)
Cargo.lock
is excluded by!**/*.lock
svelte-test/package-lock.json
is excluded by!**/package-lock.json
📒 Files selected for processing (4)
pkg/package.json
(1 hunks)svelte-test/package.json
(1 hunks)svelte-test/tests/database-functions/float-negate.test.ts
(1 hunks)svelte-test/tests/database-functions/float-sum.test.ts
(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
svelte-test/package.json
📄 CodeRabbit inference engine (CLAUDE.md)
In the Svelte test app, depend on the sqlite-web package via the locally packed tarball produced by npm pack
Files:
svelte-test/package.json
🧠 Learnings (8)
📓 Common learnings
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.178Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.062Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
📚 Learning: 2025-09-17T06:55:20.178Z
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.178Z
Learning: Applies to svelte-test/package.json : In the Svelte test app, depend on the sqlite-web package via the locally packed tarball produced by npm pack
Applied to files:
svelte-test/package.json
📚 Learning: 2025-09-17T08:04:44.062Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#6
File: svelte-test/tests/database-functions/float-sum.test.ts:78-86
Timestamp: 2025-09-17T08:04:44.062Z
Learning: In svelte-test/tests/database-functions/float-sum.test.ts, the schema defines `amount TEXT NOT NULL` but the NULL value handling tests attempt to insert NULL values, creating a constraint violation that prevents the tests from passing.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
svelte-test/tests/database-functions/float-sum.test.ts
📚 Learning: 2025-09-17T17:17:41.827Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.827Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies [a-f] characters, preserving the 'x' in '0x' prefixes, so it won't create conflicts with tests that reject '0X' prefixes.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
svelte-test/tests/database-functions/float-sum.test.ts
📚 Learning: 2025-09-17T17:17:41.827Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:105-119
Timestamp: 2025-09-17T17:17:41.827Z
Learning: The toMixedCase function in svelte-test/tests/fixtures/float-utils.ts only modifies characters matching /[a-f]/ (hex digits a-f), preserving the 'x' in '0x' prefixes and all other characters unchanged, so it won't create conflicts with tests that reject '0X' prefixes.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
svelte-test/tests/database-functions/float-sum.test.ts
📚 Learning: 2025-09-17T17:09:58.740Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#11
File: svelte-test/tests/database-functions/float-negate.test.ts:64-72
Timestamp: 2025-09-17T17:09:58.740Z
Learning: FLOAT_SUM functionality is available and working in the codebase, so tests can rely on it without needing availability checks or gating logic.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
svelte-test/tests/database-functions/float-sum.test.ts
📚 Learning: 2025-08-27T05:59:04.254Z
Learnt from: findolor
PR: rainlanguage/sqlite-web#5
File: svelte-test/tests/database-functions/bigint-sum.test.ts:2-7
Timestamp: 2025-08-27T05:59:04.254Z
Learning: In the sqlite-web repository, the user prefers to keep .js extensions when importing TypeScript files in test files, even in Vitest environments. This is acceptable and should not be flagged as an issue.
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
📚 Learning: 2025-09-17T06:55:20.178Z
Learnt from: CR
PR: rainlanguage/sqlite-web#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-17T06:55:20.178Z
Learning: Applies to packages/sqlite-web-core/src/database_functions.rs : Integrate and expose rain.math.float-backed custom database functions for SQLite queries
Applied to files:
svelte-test/tests/database-functions/float-negate.test.ts
svelte-test/tests/database-functions/float-sum.test.ts
🧬 Code graph analysis (2)
svelte-test/tests/database-functions/float-negate.test.ts (2)
svelte-test/tests/fixtures/float-utils.ts (4)
createFloatHexMap
(50-56)withoutPrefix
(33-35)decodeFloatHex
(20-31)toMixedCase
(37-48)svelte-test/tests/fixtures/test-helpers.ts (2)
createTestDatabase
(6-22)cleanupDatabase
(173-201)
svelte-test/tests/database-functions/float-sum.test.ts (1)
svelte-test/tests/fixtures/float-utils.ts (1)
createFloatHexMap
(50-56)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: test
- GitHub Check: test
🔇 Additional comments (5)
pkg/package.json (1)
15-15
: LGTM: trailing newline only.No functional change; package metadata remains consistent.
svelte-test/tests/database-functions/float-sum.test.ts (2)
30-40
: Good: centralized hex fixtures.Using createFloatHexMap with decimal inputs improves readability and consistency across tests.
545-558
: Follow-up if keeping NOT NULL (not recommended): gate or restructure NULL tests.If you don’t relax the schema, these inserts will fail and subsequent SELECT expectations won’t be meaningful. Prefer the schema fix above or build the NULL cases via SELECT literals instead of table rows.
svelte-test/tests/database-functions/float-negate.test.ts (2)
100-115
: Mixed‑case hex test is sound.toMixedCase preserves the 'x' in '0x', so this won’t conflict with the 0X‑rejection test.
117-135
: Nice: involution check (double negate).Covers negative, zero, and positive.
Caution
Chained PR. Do not merge before #6
Motivation
See issue: #10
Solution
Checks
By submitting this for review, I'm confirming I've done the following:
fix #10
Summary by CodeRabbit
New Features
Tests
Chores