@@ -41,25 +41,34 @@ public class ASTOrderBy: SelectConstraint {
4141}
4242
4343extension ASTOrderBy : Serializable {
44- public func serialize( with serializationContext: SerializationContext ) throws -> String {
45- let expressionString = try self . expression. serialize ( with: serializationContext)
46- var result = " ORDER BY \( expressionString) "
47- if let collateName = self . collateName {
48- result += " COLLATE " + collateName
49- }
50- if let order = self . order {
51- result += " " + order. serialize ( with: serializationContext)
52- }
53- if let nullsStatus = self . nullsStatus {
54- result += " NULLS "
55- switch nullsStatus {
56- case . first:
57- result += " FIRST "
58- case . last:
59- result += " LAST "
44+ public func serialize( with serializationContext: SerializationContext ) -> Result < String , Error > {
45+ switch self . expression. serialize ( with: serializationContext) {
46+ case . success( let expressionString) :
47+ var result = " ORDER BY \( expressionString) "
48+ if let collateName = self . collateName {
49+ result += " COLLATE " + collateName
50+ }
51+ if let order = self . order {
52+ switch order. serialize ( with: serializationContext) {
53+ case . success( let orderString) :
54+ result += " " + orderString
55+ case . failure( let error) :
56+ return . failure( error)
57+ }
58+ }
59+ if let nullsStatus = self . nullsStatus {
60+ result += " NULLS "
61+ switch nullsStatus {
62+ case . first:
63+ result += " FIRST "
64+ case . last:
65+ result += " LAST "
66+ }
6067 }
68+ return . success( result)
69+ case . failure( let error) :
70+ return . failure( error)
6171 }
62- return result
6372 }
6473}
6574
0 commit comments