Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions source/classes/DatabaseLayer.cls
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,23 @@ global class DatabaseLayer {
return query?.setFrom(objectType)?.toSoql();
}

/**
* @description Creates a new SOQL query builder from a SOQL query string.
* Parses the provided SOQL string and constructs a Soql.Builder instance with the parsed components.
*
* @param soqlString The SOQL query string to parse (e.g., 'SELECT Id, Name FROM Account WHERE CreatedDate = TODAY LIMIT 10')
* @return A configured SOQL builder instance populated from the parsed query string
* @throws Soql.Parser.ParserException if the query string is invalid or cannot be parsed
*
* @example
* String queryStr = 'SELECT Id, Name FROM Account WHERE CreatedDate = TODAY ORDER BY Name ASC LIMIT 10';
* Soql query = DatabaseLayer.Soql.newQuery(queryStr);
* List<Account> accounts = query.query();
*/
global Soql newQuery(String soqlString) {
return Soql.Parser.fromString(soqlString, INSTANCE)?.toSoql();
}

private DatabaseLayer.SoqlProvider useMocks(Boolean value) {
this.useMocks = value;
return this;
Expand Down
2 changes: 1 addition & 1 deletion source/classes/MockDmlTest.cls
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private class MockDmlTest {
}
}

@IsTest
@IsTest
private static void shouldMockConvertWithNoOpportunity() {
Lead lead = (Lead) new MockRecord(Lead.SObjectType)?.withId()?.toSObject();
Database.LeadConvert leadToConvert = new Database.LeadConvert();
Expand Down
Loading
Loading