Skip to content

Commit b503bc7

Browse files
committed
Revert "fix: MSSQL count operation with our 'query_one_for::<T>'"
This reverts commit 863e679.
1 parent 4b5855e commit b503bc7

1 file changed

Lines changed: 2 additions & 28 deletions

File tree

  • canyon_macros/src/query_operations

canyon_macros/src/query_operations/read.rs

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -173,20 +173,7 @@ mod __details {
173173
quote! {
174174
async fn count() -> Result<i64, Box<(dyn std::error::Error + Send + Sync)>> {
175175
let default_db_conn = canyon_sql::core::Canyon::instance()?.get_default_connection()?;
176-
// Handle different database types for COUNT(*) operations
177-
let db_type = default_db_conn.get_database_type()?;
178-
match db_type {
179-
#[cfg(feature = "mssql")]
180-
canyon_sql::connection::DatabaseType::SqlServer => {
181-
// SQL Server COUNT(*) returns i32, convert to i64
182-
let count_i32: i32 = default_db_conn.query_one_for::<i32>(#stmt, &[]).await?;
183-
Ok(count_i32 as i64)
184-
}
185-
_ => {
186-
// PostgreSQL and MySQL COUNT(*) return i64
187-
default_db_conn.query_one_for::<i64>(#stmt, &[]).await
188-
}
189-
}
176+
default_db_conn.query_one_for(#stmt, &[]).await
190177
}
191178
}
192179
}
@@ -196,20 +183,7 @@ mod __details {
196183
async fn count_with<'a, I>(input: I) -> Result<i64, Box<(dyn std::error::Error + Send + Sync + 'a)>>
197184
where I: canyon_sql::connection::DbConnection + Send + 'a
198185
{
199-
// Handle different database types for COUNT(*) operations
200-
let db_type = input.get_database_type()?;
201-
match db_type {
202-
#[cfg(feature = "mssql")]
203-
canyon_sql::connection::DatabaseType::SqlServer => {
204-
// SQL Server COUNT(*) returns i32, convert to i64
205-
let count_i32: i32 = input.query_one_for::<i32>(#stmt, &[]).await?;
206-
Ok(count_i32 as i64)
207-
}
208-
_ => {
209-
// PostgreSQL and MySQL COUNT(*) return i64
210-
input.query_one_for::<i64>(#stmt, &[]).await
211-
}
212-
}
186+
Ok(input.query_one_for::<i64>(#stmt, &[]).await? as i64)
213187
}
214188
}
215189
}

0 commit comments

Comments
 (0)