Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pgajek2 committed May 31, 2023
1 parent 5d01b00 commit 5ebf584
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions force-app/main/default/classes/SOQL.cls
Original file line number Diff line number Diff line change
Expand Up @@ -362,32 +362,32 @@ public inherited sharing class SOQL implements Queryable {
}

public SOQL orderBy(String field) { // Order By - ASC, NULLS FIRST by default
builder.orderBys.add(new QOrderBy().with(field));
builder.orderBys.newOrderBy().with(field);
return this;
}

public SOQL orderBy(String field, String direction) { // NULLS FIRST by default
builder.orderBys.add(new QOrderBy().with(field).sortingOrder(direction));
builder.orderBys.newOrderBy().with(field).sortingOrder(direction);
return this;
}

public SOQL orderBy(SObjectField field) { // Order By - ASC, NULLS FIRST by default
builder.orderBys.add(new QOrderBy().with(field));
builder.orderBys.newOrderBy().with(field);
return this;
}

public SOQL orderBy(String relationshipName, SObjectField field) {
builder.orderBys.add(new QOrderBy().with(relationshipName, field));
builder.orderBys.newOrderBy().with(relationshipName, field);
return this;
}

public SOQL sortDesc() {
builder.orderBy.sortDesc();
builder.latestOrderBy.sortDesc();
return this;
}

public SOQL nullsLast() {
builder.orderBy.nullsLast();
builder.latestOrderBy.nullsLast();
return this;
}

Expand Down Expand Up @@ -570,7 +570,7 @@ public inherited sharing class SOQL implements Queryable {
}
}

public QOrderBy orderBy {
public QOrderBy latestOrderBy {
get {
return orderBys.recentOrderBy();
}
Expand Down Expand Up @@ -737,22 +737,22 @@ public inherited sharing class SOQL implements Queryable {
}

public SubQuery orderBy(SObjectField field) {
builder.orderBys.add(new QOrderBy().with(field));
builder.orderBys.newOrderBy().with(field);
return this;
}

public SubQuery orderBy(String relationshipName, SObjectField field) {
builder.orderBys.add(new QOrderBy().with(relationshipName, field));
builder.orderBys.newOrderBy().with(relationshipName, field);
return this;
}

public SubQuery sortDesc() {
builder.orderBy.sortDesc();
builder.latestOrderBy.sortDesc();
return this;
}

public SubQuery nullsLast() {
builder.orderBy.nullsLast();
builder.latestOrderBy.nullsLast();
return this;
}

Expand Down Expand Up @@ -1141,8 +1141,9 @@ public inherited sharing class SOQL implements Queryable {
private class QOrderBys implements QueryClause {
public List<QOrderBy> orderBys = new List<QOrderBy>();

public void add(QOrderBy orderBy) {
orderBys.add(orderBy);
public QOrderBy newOrderBy() {
orderBys.add(new QOrderBy());
return recentOrderBy();
}

public QOrderBy recentOrderBy() {
Expand Down

1 comment on commit 5ebf584

@vercel
Copy link

@vercel vercel bot commented on 5ebf584 May 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.