@@ -362,32 +362,32 @@ public inherited sharing class SOQL implements Queryable {
362362 }
363363
364364 public SOQL orderBy (String field ) { // Order By - ASC, NULLS FIRST by default
365- builder .orderBys .add ( new QOrderBy ( ).with (field ) );
365+ builder .orderBys .newOrderBy ( ).with (field );
366366 return this ;
367367 }
368368
369369 public SOQL orderBy (String field , String direction ) { // NULLS FIRST by default
370- builder .orderBys .add ( new QOrderBy ( ).with (field ).sortingOrder (direction ) );
370+ builder .orderBys .newOrderBy ( ).with (field ).sortingOrder (direction );
371371 return this ;
372372 }
373373
374374 public SOQL orderBy (SObjectField field ) { // Order By - ASC, NULLS FIRST by default
375- builder .orderBys .add ( new QOrderBy ( ).with (field ) );
375+ builder .orderBys .newOrderBy ( ).with (field );
376376 return this ;
377377 }
378378
379379 public SOQL orderBy (String relationshipName , SObjectField field ) {
380- builder .orderBys .add ( new QOrderBy ( ).with (relationshipName , field ) );
380+ builder .orderBys .newOrderBy ( ).with (relationshipName , field );
381381 return this ;
382382 }
383383
384384 public SOQL sortDesc () {
385- builder .orderBy .sortDesc ();
385+ builder .latestOrderBy .sortDesc ();
386386 return this ;
387387 }
388388
389389 public SOQL nullsLast () {
390- builder .orderBy .nullsLast ();
390+ builder .latestOrderBy .nullsLast ();
391391 return this ;
392392 }
393393
@@ -570,7 +570,7 @@ public inherited sharing class SOQL implements Queryable {
570570 }
571571 }
572572
573- public QOrderBy orderBy {
573+ public QOrderBy latestOrderBy {
574574 get {
575575 return orderBys .recentOrderBy ();
576576 }
@@ -737,22 +737,22 @@ public inherited sharing class SOQL implements Queryable {
737737 }
738738
739739 public SubQuery orderBy (SObjectField field ) {
740- builder .orderBys .add ( new QOrderBy ( ).with (field ) );
740+ builder .orderBys .newOrderBy ( ).with (field );
741741 return this ;
742742 }
743743
744744 public SubQuery orderBy (String relationshipName , SObjectField field ) {
745- builder .orderBys .add ( new QOrderBy ( ).with (relationshipName , field ) );
745+ builder .orderBys .newOrderBy ( ).with (relationshipName , field );
746746 return this ;
747747 }
748748
749749 public SubQuery sortDesc () {
750- builder .orderBy .sortDesc ();
750+ builder .latestOrderBy .sortDesc ();
751751 return this ;
752752 }
753753
754754 public SubQuery nullsLast () {
755- builder .orderBy .nullsLast ();
755+ builder .latestOrderBy .nullsLast ();
756756 return this ;
757757 }
758758
@@ -1141,8 +1141,9 @@ public inherited sharing class SOQL implements Queryable {
11411141 private class QOrderBys implements QueryClause {
11421142 public List <QOrderBy > orderBys = new List <QOrderBy >();
11431143
1144- public void add (QOrderBy orderBy ) {
1145- orderBys .add (orderBy );
1144+ public QOrderBy newOrderBy () {
1145+ orderBys .add (new QOrderBy ());
1146+ return recentOrderBy ();
11461147 }
11471148
11481149 public QOrderBy recentOrderBy () {
0 commit comments