mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
pass db json back as bytes
This commit is contained in:
parent
2845941a28
commit
cf6d4f1cb9
3 changed files with 5 additions and 5 deletions
|
@ -67,7 +67,7 @@ impl FromSql for SqlValue {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn db_command_bytes(ctx: &SqliteStorage, input: &[u8]) -> Result<String> {
|
||||
pub(super) fn db_command_bytes(ctx: &SqliteStorage, input: &[u8]) -> Result<Vec<u8>> {
|
||||
let req: DBRequest = serde_json::from_slice(input)?;
|
||||
let resp = match req {
|
||||
DBRequest::Query {
|
||||
|
@ -95,7 +95,7 @@ pub(super) fn db_command_bytes(ctx: &SqliteStorage, input: &[u8]) -> Result<Stri
|
|||
}
|
||||
DBRequest::ExecuteMany { sql, args } => db_execute_many(ctx, &sql, &args)?,
|
||||
};
|
||||
Ok(serde_json::to_string(&resp)?)
|
||||
Ok(serde_json::to_vec(&resp)?)
|
||||
}
|
||||
|
||||
pub(super) fn db_query_row(ctx: &SqliteStorage, sql: &str, args: &[SqlValue]) -> Result<DBResult> {
|
||||
|
|
|
@ -1525,7 +1525,7 @@ impl Backend {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn db_command(&self, input: &[u8]) -> Result<String> {
|
||||
pub fn db_command(&self, input: &[u8]) -> Result<Vec<u8>> {
|
||||
self.with_col(|col| db_command_bytes(&col.storage, input))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,8 +147,8 @@ impl Backend {
|
|||
.db_command(in_bytes)
|
||||
.map_err(|e| DBError::py_err(e.localized_description(&self.backend.i18n())))
|
||||
});
|
||||
let out_string = out_res?;
|
||||
let out_obj = PyBytes::new(py, out_string.as_bytes());
|
||||
let out_bytes = out_res?;
|
||||
let out_obj = PyBytes::new(py, &out_bytes);
|
||||
Ok(out_obj.into())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue