MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / sqlite_query_as

Function sqlite_query_as

aiscript-vm/src/stdlib/db/sqlite.rs:205–235  ·  view source on GitHub ↗
(
    state: &mut State<'gc>,
    args: Vec<Value<'gc>>,
)

Source from the content-addressed store, hash-verified

203}
204
205fn sqlite_query_as<'gc>(
206 state: &mut State<'gc>,
207 args: Vec<Value<'gc>>,
208) -> Result<Value<'gc>, VmError> {
209 if args.len() < 2 {
210 return Err(VmError::RuntimeError(
211 "query_as() requires a class and SQL query string.".into(),
212 ));
213 }
214
215 let class = match args[0] {
216 Value::Class(class) => class,
217 _ => {
218 return Err(VmError::RuntimeError(
219 "First argument to query_as() must be a class.".into(),
220 ));
221 }
222 };
223
224 let sql = args[1].as_string()?;
225 let ctx = state.get_context();
226 let conn = state.sqlite_connection.as_ref().unwrap();
227
228 execute_typed_query(
229 ctx,
230 conn,
231 class,
232 sql.to_str().unwrap(),
233 args.into_iter().skip(2).collect(),
234 )
235}
236
237mod transaction {
238 use super::*;

Callers

nothing calls this directly

Calls 7

RuntimeErrorClass · 0.85
lenMethod · 0.80
as_stringMethod · 0.80
get_contextMethod · 0.80
to_strMethod · 0.80
execute_typed_queryFunction · 0.70
as_refMethod · 0.45

Tested by

no test coverage detected