Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

add support for numerics#1324

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
montanalow merged 1 commit intomasterfrommontana/1041
Feb 22, 2024
Merged

add support for numerics#1324

montanalow merged 1 commit intomasterfrommontana/1041
Feb 22, 2024

Conversation

montanalow
Copy link
Contributor

@montanalowmontanalow merged commitc7494db intomasterFeb 22, 2024
@montanalowmontanalow deleted the montana/1041 branchFebruary 22, 2024 02:45
Copy link

@eeeebbbbrrrreeeebbbbrrrr left a comment

Choose a reason for hiding this comment

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

Just a quick look, but this code is generally structured the way you gotta do it. It always feels wrong to enumerate a hardcoded list of type oids/names, but that's just kinda the nature of the beast with Rust and Postgres.

Comment on lines 990 to 994
"int8" => row[column.position].value::<i64>().unwrap().map(|v| v.to_string()),
"float4" => row[column.position].value::<f32>().unwrap().map(|v| v.to_string()),
"float8" => row[column.position].value::<f64>().unwrap().map(|v| v.to_string()),
"numeric" => row[column.position].value::<AnyNumeric>().unwrap().map(|v| v.to_string()),
"bpchar" | "text" | "varchar" => {
Copy link

@eeeebbbbrrrreeeebbbbrrrrFeb 22, 2024
edited
Loading

Choose a reason for hiding this comment

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

Hey!@montanalow asked me to take a quick look here.

I feel like these string types names would be better as OID values. pgrx has them all inpg_sys::, likepg_sys::INT8OID,pg_sys::NUMERICOID,pg_sys::NUMERICARRAYOID, and so on. It looks like this is the approach you use up inmodel.rs already.

I guess you'd have to figure out the type oids wherever you construct theColumn entries, but that doesn't seem too difficult. I think in that SELECT statement around line 505 you could writeudt_name::text::regtype::oid instead ofudt_name::TEXT.

Comparing on Oid value will be a little more performant, I suppose, and it'll future proof you from accidentally making type-os in the code.

Comment on lines 1105 to 1107
_ => error!(
"Unhandled type for quantitative scalar column: {} {:?}",
column.name, column.pg_type
Copy link

@eeeebbbbrrrreeeebbbbrrrrFeb 22, 2024
edited
Loading

Choose a reason for hiding this comment

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

And now that you have the type oids, youcould call its output function here and just get its string representation from Postgres. Who knows if it'd then be something you could otherwise handle, but maybe?

Same thing around line 1090 for the array case.

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

@eeeebbbbrrrreeeebbbbrrrreeeebbbbrrrr left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Automatically convert Postgres arbitrary precision numeric to rust f32.
2 participants
@montanalow@eeeebbbbrrrr

[8]ページ先頭

©2009-2025 Movatter.jp