File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,14 @@ extension QueryRepresentable {
158
158
public func count( ) throws -> Int {
159
159
let query = try makeQuery ( )
160
160
query. action = . count
161
- return try query. raw ( ) . int ?? 0
161
+
162
+ let raw = try query. raw ( )
163
+
164
+ guard let count = raw [ 0 , " _fluent_count " ] ? . int else {
165
+ throw QueryError . notSupported ( " Count not supported. " )
166
+ }
167
+
168
+ return count
162
169
}
163
170
164
171
//MARK: Create
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ open class GeneralSQLSerializer: SQLSerializer {
73
73
var statement : [ String ] = [ ]
74
74
var values : [ Node ] = [ ]
75
75
76
- statement += " SELECT COUNT(*) FROM "
76
+ statement += " SELECT COUNT(*) as _fluent_count FROM "
77
77
statement += sql ( table)
78
78
79
79
if !unions. isEmpty {
You can’t perform that action at this time.
0 commit comments