Skip to content

Feature/typeof#265

Open
stackasaur wants to merge 15 commits intobeyond-the-cloud-dev:release/v6.9.0from
stackasaur:feature/typeof
Open

Feature/typeof#265
stackasaur wants to merge 15 commits intobeyond-the-cloud-dev:release/v6.9.0from
stackasaur:feature/typeof

Conversation

@stackasaur
Copy link
Contributor

@stackasaur stackasaur commented Feb 4, 2026

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [?] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Test improvements
  • CI/CD improvements

Changes Made

  • Added support for TypeOf
  • Potentially breaking for user implementations as Queryable interface was modified

Related Issues

Fixes #235
Closes #

Testing

  • All existing tests pass (npm test)
  • Added new tests for new functionality
  • Tested in scratch org
  • Linting passes (npm run lint)
  • Code formatting is correct (npm run prettier:verify)

Screenshots

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

String query = SOQL.of(Event.sObjectType)
.with(
  SOQL.type.of(Event.WhatId)
  .when(Account.sObjectType).then(Account.Name)
  .when(Opportunity.sObjectType).then(Opportunity.Name)
  .whenElse('Name')
)
.toString();
System.debug(query);

// outputs
// SELECT TYPEOF What WHEN Account THEN Name WHEN Opportunity THEN Name ELSE Name END FROM Event

@vercel
Copy link

vercel bot commented Feb 4, 2026

@stackasaur is attempting to deploy a commit to the Beyond The Cloud Team on Vercel.

A member of the Team first needs to authorize it.

@stackasaur
Copy link
Contributor Author

stackasaur commented Feb 4, 2026

Haven't written unit tests yet.
Wanted some feedback on the code first as it's my first feature addition to this repo.

I added the neccesary classes to add the TypeOf fields as a component of SoqlFields as that seemed like the most logical place for the logic.

@pgajek2

@pgajek2 pgajek2 changed the base branch from main to release/v6.8.0 February 4, 2026 07:16
@pgajek2
Copy link
Member

pgajek2 commented Feb 4, 2026

Haven't written unit tests yet. Wanted some feedback on the code first as it's my first feature addition to this repo.

I added the neccesary classes to add the TypeOf fields as a component of SoqlFields as that seemed like the most logical place for the logic.

@pgajek2

@stackasaur perfect!

I'll review it as soon I'll have time!

Copy link
Member

@pgajek2 pgajek2 left a comment

Choose a reason for hiding this comment

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

I like it! Nice work!

If you disagree with anything, feel free to raise it.

@stackasaur
Copy link
Contributor Author

@pgajek2

What is the expected behavior of situations like this:

TYPEOF can’t be used in queries with GROUP BY, GROUP BY ROLLUP, GROUP BY CUBE, and HAVING.

Throw Exceptions?
Let SFDC throw it when executed?
Clean in up for the user?

@stackasaur
Copy link
Contributor Author

@pgajek2

I've addressed all of your comments

@pgajek2
Copy link
Member

pgajek2 commented Feb 4, 2026

@pgajek2

What is the expected behavior of situations like this:

TYPEOF can’t be used in queries with GROUP BY, GROUP BY ROLLUP, GROUP BY CUBE, and HAVING.

Throw Exceptions? Let SFDC throw it when executed? Clean in up for the user?

I would say: Let SFDC throw it when executed - as it's default behaviour, let's keep it in this way.

@pgajek2
Copy link
Member

pgajek2 commented Feb 4, 2026

@stackasaur all looks good, you can continue with the unit tests.

@stackasaur
Copy link
Contributor Author

@pgajek2 ,

It doesn't seem that any relationship fields are valid in the Else clause, so I'm going to remove all of those

@stackasaur
Copy link
Contributor Author

Tests completed. Updating documentation now

@stackasaur
Copy link
Contributor Author

@pgajek2 ,
I've updated documentation to cover usage.

@@ -0,0 +1,199 @@
---
Copy link
Member

Choose a reason for hiding this comment

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

Very nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what your preference for examples are. I started providing one for each method, but they all looked the same, so I scaled it back to just the one since all usage follows the same pattern.

@stackasaur
Copy link
Contributor Author

@pgajek2

Modified tests to look more like the others
Wrote documentation within API section

I think we're good

@stackasaur stackasaur marked this pull request as ready for review February 19, 2026 14:01
@pgajek2
Copy link
Member

pgajek2 commented Feb 23, 2026

@pgajek2

Modified tests to look more like the others

Wrote documentation within API section

I think we're good

Could you also write a test where you try do mock the result? Would it be possible?

@stackasaur
Copy link
Contributor Author

I think that should be possible.

I'll give it a go

@pgajek2 pgajek2 changed the base branch from release/v6.8.0 to release/v6.9.0 March 2, 2026 20:59
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.

TYPEOF Support

3 participants