Conversation
Replace per-parameter driver encoding calls with a single
value_to_<driver> helper plus runtime.prepare + list.fold, so native
adapters consume the same RawQuery encoding pipeline as the generic
runtime path.
- Emit a value_to_pog / value_to_sqlight helper at the top of each
adapter file, mapping runtime.Value to the driver's Value type
- Generate each query function via runtime.prepare(q, p) followed by
list.fold(values, query, fn(acc, v) { driver.parameter(acc, helper(v)) })
- Drop per-param render_param_value_expr, render_list_param_value_expr
and render_slice_expansion_line; slice expansion now happens inside
runtime.prepare
- Delegate enum-to-string and array conversion to the params module so
the adapter layer stays driver-agnostic
Closes #299
ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe pull request refactors SQLode's adapter code generation, replacing slice placeholder expansion with a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Summary
Rework the native
pog/sqlightadapter codegen so generated query functions consume the sameRawQuery.encodepipeline that powersruntime.prepare. Each adapter file now declares a singlevalue_to_<driver>helper, and every query function walks the encodedList(Value)throughlist.fold, eliminating the per-parameter driver encoding calls and the ad-hoc slice expansion logic.Changes
src/sqlode/codegen/adapter.gleamvalue_to_pog/value_to_sqlighthelper at the top of the file, mappingruntime.Value→ driverValuerender_prepare_lineshelper centralises theruntime.prepare(q, p)+list.foldscaffoldingrender_pog_query_call/render_pog_exec_last_id/render_sqlight_query_call/render_sqlight_exec_last_idto use the helperrender_param_value_expr,render_list_param_value_expr,render_slice_expansion_line,render_pog_params_simple,render_pog_params_with_slices,render_sqlight_params_simple,render_sqlight_params_with_slicesgleam/listimport onhas_paramsinstead ofhas_slicestest/codegen_test.gleammodels.status_to_string(v)/pog.array(pog.text)now live in the params module, not the adapterDesign Decisions
value_to_<driver>helper per adapter file keeps the generated code small and recursive array support is a natural one-liner (pog.array(value_to_pog, vs)).runtime.prepare, so the adapter layer only needs to fold the resultingList(Value); this removes a large amount of conditional rendering.Limitations
sqlighthas no native array type, soSqlArrayfalls through tosqlight.null()invalue_to_sqlight. Array support for SQLite remains a separate concern.Closes #299
Summary by CodeRabbit