fix: complete migration from string interpolation to parameterized query binds#432
fix: complete migration from string interpolation to parameterized query binds#432VJ-yadav wants to merge 2 commits intoAltimateAI:mainfrom
Conversation
…ery binds
Replace all remaining .replace("{placeholder}", ...) patterns with
parameterized ? placeholders and binds arrays across finops and schema
modules. Also migrates warehouse-advisor.ts which was missed in AltimateAI#277.
Updates tests to verify binds are passed correctly.
Fixes AltimateAI#290
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review.
Tip: disable this comment in your organization's Code Review settings.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughSQL construction across FinOps and schema modules was migrated from placeholder replacement and inline interpolation to explicit clause concatenation and parameterized binds. Several builders now return Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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 `@packages/opencode/src/altimate/native/finops/query-history.ts`:
- Line 58: The Postgres path is receiving a SQL string with a literal "LIMIT ?"
because getQueryHistory() is appending POSTGRES_HISTORY_SQL plus [limit] while
the Postgres driver (packages/drivers/src/postgres.ts) ignores _binds; fix by
either (A) rendering the numeric limit into POSTGRES_HISTORY_SQL in
getQueryHistory() so the SQL contains "LIMIT <number>" (keep
POSTGRES_HISTORY_SQL updated) or (B) implement bind support in the Postgres
driver (handle _binds in the code in packages/drivers/src/postgres.ts so it
replaces parameter placeholders with bound values) — pick one approach and apply
it consistently so getQueryHistory(), POSTGRES_HISTORY_SQL and the Postgres
driver agree on binds vs rendered values.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8d51b164-0724-4938-88e9-1a07fcf5fb4d
📒 Files selected for processing (6)
packages/opencode/src/altimate/native/finops/credit-analyzer.tspackages/opencode/src/altimate/native/finops/query-history.tspackages/opencode/src/altimate/native/finops/role-access.tspackages/opencode/src/altimate/native/finops/warehouse-advisor.tspackages/opencode/src/altimate/native/schema/tags.tspackages/opencode/test/altimate/schema-finops-dbt.test.ts
…pport The Postgres driver ignores the binds parameter, so LIMIT ? would be sent as literal text and fail. Render LIMIT inline for Postgres while other warehouses use parameterized binds.
Summary
Completes the migration started in #277. All remaining
.replace("{placeholder}", ...)patterns are now replaced with parameterized?placeholders andbindsarrays across finops and schema modules.Files changed:
credit-analyzer.ts— removed{warehouse_filter}placeholderquery-history.ts— removed{user_filter},{warehouse_filter},{limit}placeholdersrole-access.ts— removed{role_filter},{object_filter},{grantee_filter},{user_filter}placeholderstags.ts— removed{tag_filter}placeholderwarehouse-advisor.ts— replaced 6x{days}string interpolation with?binds, updated return type to{ sql, binds }Test Plan
bun test test/altimate/schema-finops-dbt.test.ts— 56 pass, 0 failturbo typecheck— all 5 packages passgrep -r '.replace("{' packages/opencode/src/altimate/native/— zero matches remainingChecklist
Fixes #290
Summary by CodeRabbit