MCPcopy Index your code
hub / github.com/RustPython/RustPython / build_row_cast_map

Method build_row_cast_map

crates/stdlib/src/_sqlite3.rs:1996–2040  ·  view source on GitHub ↗
(
            &self,
            st: &SqliteStatementRaw,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1994 }
1995
1996 fn build_row_cast_map(
1997 &self,
1998 st: &SqliteStatementRaw,
1999 vm: &VirtualMachine,
2000 ) -> PyResult<Vec<Option<PyObjectRef>>> {
2001 let detect_types = self.connection.detect_types.load(Ordering::Relaxed);
2002 if detect_types == 0 {
2003 return Ok(vec![]);
2004 }
2005
2006 let mut cast_map = vec![];
2007 let num_cols = st.column_count();
2008
2009 for i in 0..num_cols {
2010 if detect_types & PARSE_COLNAMES != 0 {
2011 let col_name = st.column_name(i);
2012 let col_name = ptr_to_str(col_name, vm)?;
2013 let col_name = col_name
2014 .chars()
2015 .skip_while(|&x| x != '[')
2016 .skip(1)
2017 .take_while(|&x| x != ']')
2018 .flat_map(|x| x.to_uppercase())
2019 .collect::<String>();
2020 if let Some(converter) = converters().get_item_opt(&col_name, vm)? {
2021 cast_map.push(Some(converter.clone()));
2022 continue;
2023 }
2024 }
2025 if detect_types & PARSE_DECLTYPES != 0 {
2026 let decltype = st.column_decltype(i);
2027 let decltype = ptr_to_str(decltype, vm)?;
2028 if let Some(decltype) = decltype.split_terminator(&[' ', '(']).next() {
2029 let decltype = decltype.to_uppercase();
2030 if let Some(converter) = converters().get_item_opt(&decltype, vm)? {
2031 cast_map.push(Some(converter.clone()));
2032 continue;
2033 }
2034 }
2035 }
2036 cast_map.push(None);
2037 }
2038
2039 Ok(cast_map)
2040 }
2041 }
2042
2043 impl Constructor for Cursor {

Callers 1

executeMethod · 0.80

Calls 14

ptr_to_strFunction · 0.85
convertersFunction · 0.85
column_countMethod · 0.80
column_nameMethod · 0.80
charsMethod · 0.80
to_uppercaseMethod · 0.80
get_item_optMethod · 0.80
column_decltypeMethod · 0.80
SomeClass · 0.50
loadMethod · 0.45
skipMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected