@@ -391,15 +391,20 @@ class QueryTests: XCTestCase {
391
391
let value = TestCodable ( int: 1 , string: " 2 " , bool: true , float: 3 , double: 4 ,
392
392
date: Date ( timeIntervalSince1970: 0 ) , optional: nil , sub: value1)
393
393
let update = try emails. update ( value)
394
- let encodedJSON = try JSONEncoder ( ) . encode ( value1)
395
- let encodedJSONString = String ( data: encodedJSON, encoding: . utf8) !
396
- assertSQL (
397
- """
398
- UPDATE \" emails \" SET \" int \" = 1, \" string \" = '2', \" bool \" = 1, \" float \" = 3.0, \" double \" = 4.0,
399
- \" date \" = '1970-01-01T00:00:00.000', \" sub \" = ' \( encodedJSONString) '
400
- """ . replacingOccurrences ( of: " \n " , with: " " ) ,
401
- update
402
- )
394
+
395
+ // NOTE: As Linux JSON decoding doesn't order keys the same way, we need to check prefix, suffix,
396
+ // and extract JSON to decode it and check the decoded object.
397
+
398
+ let expectedPrefix = " UPDATE \" emails \" SET \" int \" = 1, \" string \" = '2', \" bool \" = 1, \" float \" = 3.0, \" double \" = 4.0, \" date \" = '1970-01-01T00:00:00.000', \" sub \" = ' "
399
+ let expectedSuffix = " ' "
400
+
401
+ let sql = update. asSQL ( )
402
+ XCTAssert ( sql. hasPrefix ( expectedPrefix) )
403
+ XCTAssert ( sql. hasSuffix ( expectedSuffix) )
404
+
405
+ let extractedJSON = String ( sql [ sql. index ( sql. startIndex, offsetBy: expectedPrefix. count) ..< sql. index ( sql. endIndex, offsetBy: - expectedSuffix. count) ] )
406
+ let decodedJSON = try JSONDecoder ( ) . decode ( TestCodable . self, from: extractedJSON. data ( using: . utf8) !)
407
+ XCTAssertEqual ( decodedJSON, value1)
403
408
}
404
409
405
410
func test_delete_compilesDeleteExpression( ) {
0 commit comments