Skip to content

Commit

Permalink
Optimize try_get when pre is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
tyt2y3 committed Aug 2, 2024
1 parent 2c70ad1 commit 9675dd0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/executor/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ pub trait TryGetable: Sized {

/// Get a value from the query result with prefixed column name
fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result<Self, TryGetError> {
let index = format!("{pre}{col}");
Self::try_get_by(res, index.as_str())
if pre.is_empty() {
Self::try_get_by(res, col)
} else {
Self::try_get_by(res, format!("{pre}{col}").as_str())
}
}

/// Get a value from the query result based on the order in the select expressions
Expand Down

0 comments on commit 9675dd0

Please sign in to comment.