Skip to content

Commit 2c75f9d

Browse files
committed
feat(core): Update rusqlite backend
1 parent 990f079 commit 2c75f9d

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

geekorm-core/src/backends/rusqlite.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
//! # }
3333
//! ```
3434
35+
#[cfg(feature = "log")]
3536
use log::debug;
3637
use rusqlite::ToSql;
3738
use serde_rusqlite::*;
@@ -50,7 +51,10 @@ impl GeekConnection for rusqlite::Connection {
5051
+ serde::de::DeserializeOwned,
5152
{
5253
let query = T::query_create().build()?;
53-
debug!("Create Table Query :: {:?}", query.to_str());
54+
#[cfg(feature = "log")]
55+
{
56+
debug!("Create Table Query :: {:?}", query.to_str());
57+
}
5458
connection
5559
.execute(query.to_str(), ())
5660
.map_err(|e| crate::Error::RuSQLiteError(e.to_string()))?;
@@ -64,7 +68,10 @@ impl GeekConnection for rusqlite::Connection {
6468
where
6569
T: serde::de::DeserializeOwned,
6670
{
67-
debug!("Query :: {:?}", query.to_str());
71+
#[cfg(feature = "log")]
72+
{
73+
debug!("Query :: {:?}", query.to_str());
74+
}
6875
let mut statement = connection
6976
.prepare(query.to_str())
7077
.map_err(|e| crate::Error::RuSQLiteError(e.to_string()))?;
@@ -74,7 +81,10 @@ impl GeekConnection for rusqlite::Connection {
7481
} else {
7582
rusqlite::params_from_iter(query.values.into_iter())
7683
};
77-
debug!("Query Params :: {:?}", params);
84+
#[cfg(feature = "log")]
85+
{
86+
debug!("Query Params :: {:?}", params);
87+
}
7888

7989
let mut results = Vec::new();
8090

@@ -97,7 +107,10 @@ impl GeekConnection for rusqlite::Connection {
97107
where
98108
T: serde::de::DeserializeOwned,
99109
{
100-
debug!("Query First :: {:?}", query.to_str());
110+
#[cfg(feature = "log")]
111+
{
112+
debug!("Query First :: {:?}", query.to_str());
113+
}
101114
let mut statement = connection
102115
.prepare(query.to_str())
103116
.map_err(|e| crate::Error::RuSQLiteError(e.to_string()))?;
@@ -107,7 +120,10 @@ impl GeekConnection for rusqlite::Connection {
107120
} else {
108121
rusqlite::params_from_iter(query.values.into_iter())
109122
};
110-
debug!("Query First Params :: {:?}", params);
123+
#[cfg(feature = "log")]
124+
{
125+
debug!("Query First Params :: {:?}", params);
126+
}
111127

112128
let mut res = from_rows::<T>(
113129
statement
@@ -128,7 +144,10 @@ impl GeekConnection for rusqlite::Connection {
128144
where
129145
T: serde::de::DeserializeOwned,
130146
{
131-
debug!("Execute :: {:?}", query.to_str());
147+
#[cfg(feature = "log")]
148+
{
149+
debug!("Execute :: {:?}", query.to_str());
150+
}
132151
let mut statement = connection
133152
.prepare(query.to_str())
134153
.map_err(|e| crate::Error::RuSQLiteError(e.to_string()))?;
@@ -138,7 +157,10 @@ impl GeekConnection for rusqlite::Connection {
138157
} else {
139158
rusqlite::params_from_iter(query.values.into_iter())
140159
};
141-
debug!("Execute Params :: {:?}", params);
160+
#[cfg(feature = "log")]
161+
{
162+
debug!("Execute Params :: {:?}", params);
163+
}
142164

143165
statement
144166
.execute(params)

0 commit comments

Comments
 (0)