Skip to content

Commit a5bfb5c

Browse files
committed
Fix path param shadowing by response fields
Path params (owner, repo) now always use the WHERE clause value, not the response JSON field. Fixes column collision where e.g. the response's "owner" (a nested user object) would shadow the path param "owner" (a string), breaking JOINs on those columns.
1 parent 3f9fde6 commit a5bfb5c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

crates/sqlize-core/src/datafusion/arrow_convert.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,23 @@ pub fn json_response_to_batch(
135135
}
136136

137137
/// Extract a scalar value from a JSON item for a given column.
138+
///
139+
/// Path params always use the pushed value (the user's WHERE clause),
140+
/// not the response field — even if the response has a field with the
141+
/// same name (e.g., `owner` is both a path param and a nested user object).
138142
fn extract_value(
139143
item: &serde_json::Value,
140144
col: &Column,
141145
param_values: &HashMap<ColumnName, String>,
142146
) -> Scalar {
147+
// Path params: always use the pushed value
148+
if col.role.is_required() {
149+
if let Some(v) = param_values.get(&col.name) {
150+
return Scalar::String(v.clone());
151+
}
152+
}
153+
154+
// Response fields: check JSON first, fall back to param values
143155
if let Some(map) = item.as_object() {
144156
let col_name = col.name.as_str();
145157
if let Some(v) = find_in_json(map, col_name) {

0 commit comments

Comments
 (0)