You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
More than likely I'm doing something incorrect. That being said, I am trying to work with a datetime field and extract rows by date. So, provided 100 entries over 5 days, I'd like to query for distinct days in addition to pulling out all the entries on a day by day basis.
I found reference here for how to reference the date.day portion of a datetime field, however when I try and use the 'distinct' prefix I get a "Ambiguous reference to member 'distinct'" error.
There is a bit of reference to using Date in the docs however I'm not clear enough on the full implications of what's mentioned to know if the issue with the 'distinct' prefix is a bug or functioning as designed.
Hopefully someone here can point me in the right direction. Thanks in advance, and thanks for the great library.
let db = try Connection("/path/to/db.sqlite")
let logs = Table("logs")
extension Expression where Datatype: NSDate {
var day: Expression<NSDate> {
return Expression<NSDate>("time_entry(\(template))", bindings)
}
}
let date = Expression<NSDate>("time_entry")
let id = Expression<Int64>("id")
/* This fails */
let count = try db.scalar(logs.select(date.distinct.count))
let count = try db.scalar(logs.select(date.day.distinct.count))
/* This succeeds (however is not very useful) */
let count = try db.scalar(logs.select(id.distinct.count))
The text was updated successfully, but these errors were encountered:
More than likely I'm doing something incorrect. That being said, I am trying to work with a datetime field and extract rows by date. So, provided 100 entries over 5 days, I'd like to query for distinct days in addition to pulling out all the entries on a day by day basis.
I found reference here for how to reference the date.day portion of a datetime field, however when I try and use the 'distinct' prefix I get a "Ambiguous reference to member 'distinct'" error.
I have also posted this question to stackoverflow
There is a bit of reference to using Date in the docs however I'm not clear enough on the full implications of what's mentioned to know if the issue with the 'distinct' prefix is a bug or functioning as designed.
Hopefully someone here can point me in the right direction. Thanks in advance, and thanks for the great library.
The text was updated successfully, but these errors were encountered: