Skip to content

Conversation

@aaronbauman
Copy link
Collaborator

PR for https://www.drupal.org/node/2879844

There are many things SOQL cannot do, but we can get pretty close
to mimicing Drupal database layer. This commit updates SelectQuery
to rely on Drupal\Core\Database\Query\Condition records to keep track
of where clauses, and implements as many other methods as make sense
from Drupal\Core\Database\Query\SelectInterface.

Change namespace to Drupal\salesforce\Query\

Add a SelectQueryTest unit test to verify expected syntax
for SOQL queries.

Update all other uses of SelectQuery to reflect API changes.

Still TODO:

  • update 8.x-3.x branch to deprecate uses of properties
    and methods being removed here
  • create change records
  • test these changes in more realistic scenarios

There are many things SOQL cannot do, but we can get pretty close
to mimicing Drupal database layer. This commit updates SelectQuery
to rely on Drupal\Core\Database\Query\Condition records to keep track
of where clauses, and implements as many other methods as make sense
from Drupal\Core\Database\Query\SelectInterface.

Change namespace to Drupal\salesforce\Query\

Add a SelectQueryTest unit test to verify expected syntax
for SOQL queries.

Update all other uses of SelectQuery to reflect API changes.

Still TODO:
- update 8.x-3.x branch to deprecate uses of properties
and methods being removed here
- create change records
- test these changes in more realistic scenarios
@@ -0,0 +1,240 @@
<?php
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I understand the purpose of this one. What's the advantage over just using apiCall directly?

If we're trying to move to be more Core-DB-like raw strings should probably be handled in RestClient::query

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Implemented this so to be compatible with RestClient::query, which requires a SelectInterface argument.
There's no real value in having this class - could just as easily move the layer of indirection to RestClient.

/**
* {@inheritdoc}
*/
public function addTable($table, $alias = NULL) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we actually add tables in this fashion? I think this might have to be handled on the field list

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, sort of, e.g. if you want to add a table in order to create a where condition, but not select anything from it.

Here's an example query from https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_alias.htm?search_text=alias

SELECT count()
FROM Contact c, c.Account a
WHERE a.name = 'MyriadPubs'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants