fix(native): return type casts (#7986)

This commit is contained in:
darkskygit
2024-08-27 05:53:05 +00:00
parent 6557b5d4b6
commit 10a066a52a
2 changed files with 6 additions and 8 deletions
+2 -2
View File
@@ -336,7 +336,7 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
nativeBinding = require('./affine.wasi.cjs') nativeBinding = require('./affine.wasi.cjs')
} catch (err) { } catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) { if (process.env.NAPI_RS_FORCE_WASI) {
console.error(err) loadErrors.push(err)
} }
} }
if (!nativeBinding) { if (!nativeBinding) {
@@ -344,7 +344,7 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
nativeBinding = require('@affine/native-wasm32-wasi') nativeBinding = require('@affine/native-wasm32-wasi')
} catch (err) { } catch (err) {
if (process.env.NAPI_RS_FORCE_WASI) { if (process.env.NAPI_RS_FORCE_WASI) {
console.error(err) loadErrors.push(err)
} }
} }
} }
+4 -6
View File
@@ -166,7 +166,7 @@ impl SqliteConnection {
} }
#[napi] #[napi]
pub async fn get_updates_count(&self, doc_id: Option<String>) -> napi::Result<i32> { pub async fn get_updates_count(&self, doc_id: Option<String>) -> napi::Result<i64> {
let count = match doc_id { let count = match doc_id {
Some(doc_id) => { Some(doc_id) => {
sqlx::query!( sqlx::query!(
@@ -185,9 +185,7 @@ impl SqliteConnection {
.map_err(anyhow::Error::from)? .map_err(anyhow::Error::from)?
.count .count
} }
} };
.try_into()
.unwrap();
Ok(count) Ok(count)
} }
@@ -396,14 +394,14 @@ impl SqliteConnection {
} }
#[napi] #[napi]
pub async fn get_max_version(&self) -> napi::Result<i32> { pub async fn get_max_version(&self) -> napi::Result<i64> {
// 4 is the current version // 4 is the current version
let version = sqlx::query!("SELECT COALESCE(MAX(version), 4) AS max_version FROM version_info") let version = sqlx::query!("SELECT COALESCE(MAX(version), 4) AS max_version FROM version_info")
.fetch_one(&self.pool) .fetch_one(&self.pool)
.await .await
.map_err(anyhow::Error::from)? .map_err(anyhow::Error::from)?
.max_version; .max_version;
Ok(version.try_into().unwrap()) Ok(version)
} }
#[napi] #[napi]