Skip to content

fix(core): inline TrackRow SELECT in postgres list/get methods#187

Merged
InstaZDLL merged 1 commit into
mainfrom
fix/postgres-track-query-as-literal
May 30, 2026
Merged

fix(core): inline TrackRow SELECT in postgres list/get methods#187
InstaZDLL merged 1 commit into
mainfrom
fix/postgres-track-query-as-literal

Conversation

@InstaZDLL
Copy link
Copy Markdown
Owner

@InstaZDLL InstaZDLL commented May 30, 2026

Summary

Latent build break in PostgresTrackRepository (introduced in #186): sqlx 0.9's query_as takes impl SqlSafeStr, which only accepts a 'static literal. The previous version stored the shared projection in const SELECT_TRACK_ROW: &str and composed it via format!() at runtime — the resulting String failed to coerce when waveflow-server consumed waveflow-core with features = ["postgres"].

The desktop workspace check (cargo check --workspace --all-targets) didn't catch this because it doesn't activate the postgres Cargo feature on waveflow-core — that code path is only compiled when waveflow-server's git dep pulls it in.

Fix

Inline the full NULL-cast projection at each call site in list_for_library and get_for_library. insert_for_library, update_for_library, and delete_for_library already used literal strings (their INSERT/UPDATE/DELETE-specific shapes are method-local anyway) — no change needed.

Duplication is bounded; a future schema change would have touched each branch the same way anyway.

Follow-up

Worth adding cargo check --features postgres --all-targets (or --all-features) to the workspace check loop / CI so this feature-gated path gets compiled outside of waveflow-server's build.

Test plan

  • cargo check --manifest-path src-tauri/crates/core/Cargo.toml --features postgres --all-targets
  • cargo clippy --manifest-path src-tauri/crates/core/Cargo.toml --features postgres --all-targets -- -D warnings
  • cargo test --workspace (45 passed, unchanged)

Summary by CodeRabbit

  • Refactor
    • Optimisation interne du traitement des requêtes de base de données pour améliorer la stabilité et la compatibilité.

Review Change Stack

sqlx 0.9's `query_as` argument is `impl SqlSafeStr`, which only
accepts a `'static` literal. The previous version stored the
projection in `const SELECT_TRACK_ROW: &str` and composed it via
`format!()` at runtime — the resulting `String` failed to coerce
when waveflow-server consumed waveflow-core with the `postgres`
feature enabled.

The workspace check on the desktop side (`cargo check --workspace
--all-targets`) didn't catch this because it doesn't activate the
`postgres` cargo feature on waveflow-core — that code path is only
compiled when waveflow-server's git dep pulls it in.

Fix: inline the full NULL-cast projection at each call site in
`list_for_library` and `get_for_library`. `insert_for_library`,
`update_for_library` and `delete_for_library` already used literal
strings (they had INSERT/UPDATE/DELETE-specific shapes anyway) and
didn't need changes.

Validated:
- cargo check --features postgres --all-targets (on the core crate)
- cargo clippy --features postgres --all-targets -- -D warnings
- workspace test suite still passes

Signed-off-by: InstaZDLL <github.105mh@8shield.net>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f9005178-a6a3-4446-b6bd-5c4430b84734

📥 Commits

Reviewing files that changed from the base of the PR and between 101aff5 and afebc83.

📒 Files selected for processing (1)
  • src-tauri/crates/core/src/repository/postgres/track.rs

📝 Walkthrough

Aperçu

Le repository PostgreSQL pour les pistes inligne les projections SQL dans les méthodes list_for_library et get_for_library au lieu d'utiliser une constante partagée, pour se conformer à la contrainte 'static de sqlx 0.9.

Modifications

Migration vers projections SQL inlinées

Couche / Fichier(s) Résumé
Inlining des projections SELECT
src-tauri/crates/core/src/repository/postgres/track.rs
La constante SELECT_TRACK_ROW est remplacée par des projections inlinées dans les deux méthodes. Un commentaire explique que sqlx 0.9 requiert des littéraux 'static, rendant format!() non conforme. Les chaînes d'ownership et les filtres library_id sont préservés dans list_for_library et get_for_library.

Effort d'examen estimé

🎯 3 (Modéré) | ⏱️ ~20 minutes

PRs potentiellement liées

Poème

📜 Les constantes SQL se transforment en requêtes inline,
sqlx 0.9 impose ses règles 'static si fines,
Ownership chaînes intactes, filtres préservés,
Pas de comportement nouveau, juste du code raffiné. 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Le titre décrit précisément le changement principal : l'inlining des SELECT TrackRow dans les méthodes postgres list/get. Il suit le format Conventional Commits.
Description check ✅ Passed La description couvre complètement le problème (sqlx 0.9 query_as avec 'static literal), la solution (inlining), les tests effectués et même recommande un suivi CI.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/postgres-track-query-as-literal

Comment @coderabbitai help to get the list of available commands and usage tips.

@InstaZDLL InstaZDLL added scope: backend Rust/Tauri backend (src-tauri/) type: fix Bug fix size: m 50-200 lines labels May 30, 2026
@InstaZDLL InstaZDLL self-assigned this May 30, 2026
@InstaZDLL InstaZDLL merged commit 062c550 into main May 30, 2026
14 checks passed
@InstaZDLL InstaZDLL deleted the fix/postgres-track-query-as-literal branch May 30, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: backend Rust/Tauri backend (src-tauri/) size: m 50-200 lines type: fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant