Skip to content

Allow conversion of a Queryable into a SubQuery or InnerJoin #303

Description

@stackasaur

Is your feature request related to a problem? Please describe.
Under the hood, SoqlSubQuery, Soql, and InnerJoin all use SoqlBuilder. There should be a built in way to convert an instance of Soql into a SubQuery or InnerJoin so we can leverage our selector classes.

A common pain point I hear is that the current way to use SubQuery and InnerJoin is frustrating because it requires a lot of extra overhead on top of the logic already written in defined selector classes.

Describe the solution you'd like
There should either be a "results" type method on Queryable to return an InnerJoin/SubQuery, or a method on InnerJoin/SubQuery to wrap a Queryable instance

// something like this:
SOQL.subquery.of('Contacts').wraps(SOQL_Contact.query())
SOQL.innerJoin.of(SOQL_Contact.query())

// or something like this
SOQL.of(Contact.sObjectType)
  .toSubQuery('Contacts')
SOQL.of(Contact.sObjectType)
  .toInnerJoin()

edit: I now believe the ideal syntax would be to add the following methods to Queryable for conversion into SubQuery or InnerJoin

interface Queryable {
  SubQuery toSubQueryOf(String relationshipName);
  InnerJoin toInnerJoinOn(SObjectField joinOn);
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions