diff --git a/Sources/FeatherDatabase/Database/Query/DatabaseQueryCount.swift b/Sources/FeatherDatabase/Database/Query/DatabaseQueryCount.swift index fe53ef9..f0f0d6a 100644 --- a/Sources/FeatherDatabase/Database/Query/DatabaseQueryCount.swift +++ b/Sources/FeatherDatabase/Database/Query/DatabaseQueryCount.swift @@ -22,12 +22,17 @@ extension DatabaseQueryCount { on db: Database ) async throws -> UInt { try await db.run { sql in - try await sql + let value = + try await sql .select() .from(Row.tableName) - .column(SQLFunction("COUNT", args: SQLLiteral.all), as: "count") + .column( + SQLFunction("COUNT", args: SQLLiteral.all), + as: "count" + ) .applyFilter(filter) - .first(decodingColumn: "count", as: UInt.self) ?? 0 + .first(decodingColumn: "count", as: Int.self) ?? 0 + return UInt(value) } } } diff --git a/Sources/FeatherDatabase/Database/Query/DatabaseQueryList.swift b/Sources/FeatherDatabase/Database/Query/DatabaseQueryList.swift index ea5856c..bd2dec4 100644 --- a/Sources/FeatherDatabase/Database/Query/DatabaseQueryList.swift +++ b/Sources/FeatherDatabase/Database/Query/DatabaseQueryList.swift @@ -29,7 +29,7 @@ extension DatabaseQueryList { .column(SQLFunction("COUNT", args: SQLLiteral.all), as: "count") .applyFilter(query.filter) .applyOrders(query.orders) - .first(decodingColumn: "count", as: UInt.self) ?? 0 + .first(decodingColumn: "count", as: Int.self) ?? 0 let items = try await sql @@ -41,7 +41,7 @@ extension DatabaseQueryList { .applyPage(query.page) .all(decoding: Row.self) - return .init(items: items, total: total) + return .init(items: items, total: UInt(total)) } } }