-
Notifications
You must be signed in to change notification settings - Fork 71
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
api : fix/optimizes utils.rs #45
base: main
Are you sure you want to change the base?
Conversation
looks like https://docs.rs/sqlx/latest/sqlx/trait.Column.html |
…into modify_api_utils
After many attempts, I found that the tokio version is insufficient, so it cannot be used directly. If it is upgraded, there may be other effects. My suggestion here is to restore this part to the previous one or use my previous more repetitive method to judge the empty space. I have practiced it and there is no problem, but the code may look a bit repetitive. |
tokio (v1) and tokio-postgres (v0.7) are both the newest version. but i have no problem upgrading dependencies as needed. however, shouldn't it just work to get the types as Type::INT2 => json!(row.get::<_, i16>(i)),
...
Type::JSON | Type::JSONB => row.get::<_, Option<Value>>(i),
Type::UUID => json!(row.get::<_, Option<Uuid>>(i).map(ToString::to_string)) ? |
OK, this is also a good method, it works very well, I think is_null is more concise, so I have been thinking about this problem |
Pull Request Summary
Summary
This PR fixes potential panics in pagination logic, enhances JSON conversion by handling nullable fields and logging unhandled PostgreSQL types, and optimizes performance by reducing redundant operations.
Changes
Pagination Logic:
total_pages
is at least1
to prevent panics whentotal_count
is0
.rows_to_json
Enhancements:NULL
values appropriately in JSON output.General Improvements:
get_column_names
.Benefits
NULL
values and logs unsupported types for better debugging.