Closed perbrondum closed 2 years ago
// Fails in 9.06 BETA with date format
@available(iOS 15.0.0, *)
private func simpleDateQuery() async throws
{
DB.salesforce.identity().sink(receiveCompletion: { (completion) in
switch completion {
case .finished:
break
case let .failure(error) :
print("Failed to login. Error: \(error)")
}
}) { identity in
let userId = identity.userID
let userSoql = "select name from account where lastmodifiedDate > 2023-01-01T12:00:00.000+0100"
// print(userSoql)
DB.salesforce.query(soql: userSoql).sink(receiveCompletion: { (completion) in
switch completion {
case let .failure(error):
testResults[8] = "simpleDateQuery, Failure"
testErrors[8] = error
print("Failed query(8) SFDC. Error: \(error)")
case .finished:
testResults[8] = "simpleDateQuery, Success"
printOut()
}
}, receiveValue: { (userData : QueryResult<User>) in
//
}).store(in: &subscriptions)
}.store(in: &subscriptions)
}
@perbrondum the query will work if you use the date/time format YYYY-MM-DDThh:mm:ssZ
i.e. select name from account where lastmodifiedDate > 2023-01-01T11:00:00Z
(adjusted to UTC).
Your original query also fails with the same error when I try it in Workbench's "REST Explorer," so I don't believe the problem lies within Swiftly Salesforce. Per the docs, the format you used is acceptable, but still only the above format works in Workbench.
@perbrondum -- sorry, disregard my last comment; it is indeed a bug in Swiftly Salesforce: I should have checked for "+" in the time zone offset and then URL-encoded it. For now, a workaround is to use UTC time format instead, i.e. YYYY-MM-DDThh:mm:ssZ
Thanks
Thanks for the quick reply.
Using "YYYY-MM-ddThh:mm:ssZ" returns "2021-12-11T21:21:53+0000" which has the same problem.
Note that any query using predicate date qualifiers like LAST_N_DAYS:n will have the same issue.
Thanks @perbrondum - I will fix this. I'm working on the version 10, and don't know yet whether it'll be faster to fix it there or in a minor release of version 9.
Fixed in version 10.0.0
Simple Date SOQL statement fails in 9.0.6 "select name from account where lastmodifiedDate > 2023-01-01T12:00:00.000+0100"
fails with: "Query Error : SalesforceError(code: "MALFORMED_QUERY", message: "\nlastmodifiedDate > 2023-01-01T12:00:00.000 0100\n ^\nERROR at Row:2:Column:48\nline 2:48 no viable alternative at character \' \'", fields: nil)"
testcase: `// Fails in 9.06 BETA with date format @available(iOS 15.0.0, *) private func simpleDateQuery() async throws { DB.salesforce.identity().sink(receiveCompletion: { (completion) in switch completion { case .finished: break case let .failure(error) : print("Failed to login. Error: (error)") } }) { identity in let userId = identity.userID
}`