MCPcopy Create free account
hub / github.com/SeaQL/sea-orm / TryGetable

Interface TryGetable

src/executor/query.rs:37–54  ·  view source on GitHub ↗

An interface to get a value from the query result

Source from the content-addressed store, hash-verified

35
36/// An interface to get a value from the query result
37pub trait TryGetable: Sized {
38 /// Get a value from the query result with an ColIdx
39 fn try_get_by<I: ColIdx>(res: &QueryResult, index: I) -> Result<Self, TryGetError>;
40
41 /// Get a value from the query result with prefixed column name
42 fn try_get(res: &QueryResult, pre: &str, col: &str) -> Result<Self, TryGetError> {
43 if pre.is_empty() {
44 Self::try_get_by(res, col)
45 } else {
46 Self::try_get_by(res, format!("{pre}{col}").as_str())
47 }
48 }
49
50 /// Get a value from the query result based on the order in the select expressions
51 fn try_get_by_index(res: &QueryResult, index: usize) -> Result<Self, TryGetError> {
52 Self::try_get_by(res, index)
53 }
54}
55
56impl From<TryGetError> for DbErr {
57 fn from(e: TryGetError) -> DbErr {

Callers

nothing calls this directly

Implementers 3

query.rssrc/executor/query.rs
event_trigger.rstests/common/features/event_trigger.rs
model.rsissues/400/src/model.rs

Calls

no outgoing calls

Tested by

no test coverage detected