Skip to content

fix(rust/core): Handle the ASCII characters from sqlstate instead of their decimal values#4141

Open
felipecrv wants to merge 1 commit intoapache:mainfrom
felipecrv:sqlstate-chars
Open

fix(rust/core): Handle the ASCII characters from sqlstate instead of their decimal values#4141
felipecrv wants to merge 1 commit intoapache:mainfrom
felipecrv:sqlstate-chars

Conversation

@felipecrv
Copy link
Contributor

No description provided.

@felipecrv felipecrv requested a review from wjones127 as a code owner March 24, 2026 23:14
@felipecrv felipecrv requested a review from lidavidm March 24, 2026 23:15
@felipecrv
Copy link
Contributor Author

I'm tired of seeing sqlstate: [48, 48, 48, 48, 48], all the time. :)

} else if c >= 32 && c <= 126 {
char::from(c as u8)
} else {
'\u{FFFD}'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can still display the value somehow instead of hiding it? (Just stringify the integer value instead?)

fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let safe_ascii = |c: c_char| -> char {
if c == 0 {
'0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd prefer something that isn't ambiguous with an actual sqlstate of '00000'.

f,
"{:?}: {} (sqlstate: {:?}, vendor_code: {})",
self.status, self.message, self.sqlstate, self.vendor_code
"{:?}: {} (sqlstate: {}{}{}{}{}, vendor_code: {})",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe what'd be better is: if sqlstate is all-NUL, omit it; if all-ASCII, stringify it; else fall back to the current representation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants