Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macro error with CockroachDB #1386

Merged
merged 1 commit into from
Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions sqlx-core/src/postgres/connection/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,16 @@ SELECT oid FROM pg_catalog.pg_type WHERE typname ILIKE $1
.fetch_all(&mut *self)
.await?;

// patch up our null inference with data from EXPLAIN
let nullable_patch = self
.nullables_from_explain(stmt_id, meta.parameters.len())
.await?;
// if it's cockroachdb skip this step #1248
if !self.stream.parameter_statuses.contains_key("crdb_version") {
// patch up our null inference with data from EXPLAIN
let nullable_patch = self
.nullables_from_explain(stmt_id, meta.parameters.len())
.await?;

for (nullable, patch) in nullables.iter_mut().zip(nullable_patch) {
*nullable = patch.or(*nullable);
for (nullable, patch) in nullables.iter_mut().zip(nullable_patch) {
*nullable = patch.or(*nullable);
}
}

Ok(nullables)
Expand Down
13 changes: 13 additions & 0 deletions sqlx-core/src/postgres/message/parameter_status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ fn bench_decode_parameter_status(b: &mut test::Bencher) {
ParameterStatus::decode(test::black_box(Bytes::from_static(DATA))).unwrap();
});
}

#[test]
fn test_decode_parameter_status_response() {
const PARAMETER_STATUS_RESPONSE: &[u8] = b"crdb_version\0CockroachDB CCL v21.1.0 (x86_64-unknown-linux-gnu, built 2021/05/17 13:49:40, go1.15.11)\0";

let message = ParameterStatus::decode(Bytes::from(PARAMETER_STATUS_RESPONSE)).unwrap();

assert_eq!(message.name, "crdb_version");
assert_eq!(
message.value,
"CockroachDB CCL v21.1.0 (x86_64-unknown-linux-gnu, built 2021/05/17 13:49:40, go1.15.11)"
);
}