Skip to content

Commit 926019d

Browse files
fix(api): point query_as!/query_scalar! param comments at #137 (#153)
* docs(api): note _as_params as the binding target for query_as! (#137) query_as! / query_scalar! validate SQL and accept $N args but the QueryAs/QueryScalar runtime builders don't yet bind them (params stored as debug strings; fetch_* forward to the non-param fetch_*_as). Point the dead-code comment and a TODO at fetch_*_as_params (added in #137) as the primitive that finishes parameter binding. * docs(api): align all query_as/query_scalar param comments (#137) Remove stale 'W3' and 'future milestone' phrasing from QueryAs::new doc and QueryScalar::params allow-reason. Both now point at issue #137 and the _as_params delegation target, consistent with the QueryAs::params comment updated in the prior commit.
1 parent c576945 commit 926019d

1 file changed

Lines changed: 19 additions & 5 deletions

File tree

hyperdb-api/src/query_as.rs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ use crate::{Connection, FromRow, Result, RowValue};
1414
#[derive(Debug)]
1515
pub struct QueryAs<T> {
1616
sql: String,
17-
// Bind parameters are stored as formatted strings for now. Full typed
18-
// parameter support (ToSqlParam) is wired in Milestone B.
19-
#[allow(dead_code, reason = "full parameter binding wired in Milestone B (W3)")]
17+
// Bind parameters are stored as formatted strings for now — the macro
18+
// accepts `$N` args and validates the SQL, but binding is not yet wired
19+
// (the `fetch_*` methods below forward to the NON-param `fetch_*_as`).
20+
//
21+
// To finish this: change `params` to hold `ToSqlParam` values and route
22+
// through `Connection::fetch_*_as_params` (added in issue #137 — the
23+
// parameterized FromRow methods are exactly the primitive this needs).
24+
#[allow(
25+
dead_code,
26+
reason = "typed parameter binding not yet wired — see issue #137"
27+
)]
2028
params: Vec<String>,
2129
_phantom: PhantomData<fn() -> T>,
2230
}
@@ -26,7 +34,8 @@ impl<T: FromRow> QueryAs<T> {
2634
/// for direct use.
2735
///
2836
/// `params` accepts `&dyn std::fmt::Debug` so the macro can pass any bind
29-
/// arguments through — the actual typed binding will be tightened in W3.
37+
/// arguments through — typed binding via `ToSqlParam` is not yet wired
38+
/// (see the `TODO(#137)` on `fetch_all` below).
3039
pub fn new(sql: &str, params: &[&dyn std::fmt::Debug]) -> Self {
3140
Self {
3241
sql: sql.to_owned(),
@@ -42,6 +51,8 @@ impl<T: FromRow> QueryAs<T> {
4251
/// Returns a `hyperdb_api::Error` on connection failure, SQL error, or
4352
/// row-mapping failure.
4453
pub fn fetch_all(self, conn: &Connection) -> Result<Vec<T>> {
54+
// TODO(#137): forward to `conn.fetch_all_as_params(&self.sql, &params)`
55+
// once `params` holds `ToSqlParam` values, to actually bind `$N` args.
4556
conn.fetch_all_as(&self.sql)
4657
}
4758

@@ -81,9 +92,12 @@ impl<T: FromRow> QueryAs<T> {
8192
#[derive(Debug)]
8293
pub struct QueryScalar<T> {
8394
sql: String,
95+
// Same gap as `QueryAs::params` — the macro validates the SQL and
96+
// accepts args, but binding isn't wired yet. Route through
97+
// `fetch_scalar_params` (or equivalent) once it exists.
8498
#[allow(
8599
dead_code,
86-
reason = "typed parameter binding wired in a future milestone"
100+
reason = "typed parameter binding not yet wired — see issue #137"
87101
)]
88102
params: Vec<String>,
89103
_phantom: PhantomData<fn() -> T>,

0 commit comments

Comments
 (0)