bigquery-derive: reject ambiguous and duplicate #[bigquery(...)] attributes at compile time
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- backend-api-design
Hướng nghiên cứu
Start with src/bigquery-derive/src/lib.rs, especially get_field_name, derive_from_row_impl, and derive_from_sql_impl, then read the proc-macro guidance in doc/contributor/howto-guide-handwritten-client-api.md. Add unit tests there for duplicate resolved names, duplicate rename options across and within attributes, and unsupported container attributes; done when each case produces a spanned compile-time error.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
google-cloud-bigquery-derive (#[derive(FromRow)] and #[derive(FromSql)]) silently accepts ambiguous and invalid #[bigquery(...)] attribute configurations instead of rejecting them with compile-time errors.
Because rejecting input that previously compiled is a breaking change to accepted macro input under the proc-macro compatibility policy (src/bigquery-derive/src/lib.rs), fixing these validation gaps before google-cloud-bigquery 1.0.0 is released (#7424) avoids requiring a major bump of google-cloud-bigquery later.
Problem Details
Per doc/contributor/howto-guide-handwritten-client-api.md:
Ambiguous input (for example, two fields mapping to the same property name after flattening) is an error, never resolved silently.
Currently in src/bigquery-derive/src/lib.rs:
- Duplicate target column /
STRUCTfield names compile silently and exhibit transport-dependent runtime behavior:derive_from_row_implandderive_from_sql_implresolve each named field's column/field name independently without checking for duplicates across the struct.- For example:
(or two fields both marked#[derive(FromRow)] struct AmbiguousRow { col: Option<String>, #[bigquery(rename = "col")] other: Option<String>, }#[bigquery(rename = "same")], orr#typecolliding with#[bigquery(rename = "type")]). - At runtime,
FromRowemits tworow.take("col")?calls:- On JSON-backed rows (
RowInner::Jsoninsrc/bigquery/src/query/row.rs), the firsttakereplaces cell"col"withSqlValueInner::Null, soothersilently receivesNone(or fails withConvertError::NotNullfor non-optional types). - On Arrow-backed rows (
RowInner::Arrowinsrc/bigquery/src/query/row.rs),takereads from theRecordBatchwithout mutating it, so bothcolandotherreceive"col"'s value.
- On JSON-backed rows (
FromSql(SqlValue::take) has the same discrepancy betweenSqlValueInner::Struct(replaces slot withNull) andSqlValueInner::Arrow(reads without mutating).
- Multiple
#[bigquery(...)]attributes on the same field short-circuit after the firstrename:- In
get_field_name(src/bigquery-derive/src/lib.rs),if let Some(name) = renamed { return Ok(name); }returns inside thefor attr in &field.attrsloop. - A second
#[bigquery(rename = "...")]on the same field is silently ignored instead of reporting a duplicaterenameerror, and a subsequent invalid attribute (e.g.,#[bigquery(rename = "a")] #[bigquery(typo = "b")]) is never parsed at all.
- In
- Duplicate
renameoptions inside a single attribute overwrite silently:#[bigquery(rename = "a", rename = "b")]overwritesrenamed = Some(lit.value())without checking ifrenamewas already specified, silently using"b".
- Container-level
#[bigquery(...)]attributes on structs are silently ignored:- Neither
derive_from_row_implnorderive_from_sql_implinspectsinput.attrs, so unsupported container attributes such as#[bigquery(rename_all = "camelCase")]on a struct compile without error and have no effect.
- Neither
Expected Behavior
- Reject structs where two or more fields resolve to the same BigQuery column /
STRUCTfield name with a spannedsyn::Error. - Inspect all
#[bigquery(...)]attributes on every field and reject duplicaterenameoptions (whether in one#[bigquery(rename = "a", rename = "b")]list or across multiple#[bigquery(...)]attributes on the same field). - Reject
#[bigquery(...)]attributes placed on the container (struct/enum/union) itself until/unless container options are explicitly supported. - Add unit tests in
src/bigquery-derive/src/lib.rscovering each error case, and take a breaking version bump ongoogle-cloud-bigquery-deriveif needed per the compatibility policy.
- Ngôn ngữ chính
- Rust
- Star
- 972
- Fork
- 163
- Merge trung bình
- 1 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 176
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của googleapis/google-cloud-rust
-
Upgrade MSRV to 1.92.0Đang mởtype: process
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
googleapis/google-cloud-rust#7466 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Upgrade Rust toolchain to 1.100Đang mởtype: process
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
googleapis/google-cloud-rust#7465 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
api: storage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
googleapis/google-cloud-rust#7344 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BytesValue in Any rejects unpadded and URL-safe base64Có thể đã có người làm @akasakariko đã nhận 19 ngày trước. Đang mởpriority: p2 type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
googleapis/google-cloud-rust#6714 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type: bug
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 75/100
googleapis/google-cloud-rust#6710 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của googleapis/google-cloud-rust
Issue tương tự
-
priority: low
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 83/100
storytold/vectorcraft#8387 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:desktop kind:test priority:p3 ready
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 91/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
obi1kenobi/cargo-semver-checks#1814 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
COMPARE.md symlink is brokenĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
BurntSushi/jiff#715 ·
Maintainer thường phản hồi trong vòng 1 ngày