Code Monkey home page Code Monkey logo

Comments (6)

afawcett avatar afawcett commented on August 14, 2024

Not sure what it is your asking for here. A configured Query Factory is exposed from fflib_SObjectSelector via the newQueryFactory method, at this point you can call whatever methods you desire before calling toSOQL. Does this help?

from fflib-apex-common.

phyopine-gscs avatar phyopine-gscs commented on August 14, 2024

@afawcett , what I meant is in fflib_SObjectSelector addQueryFactorySubselect method is calling subSelectQuery(SObjectType related) method on line 330 of fflib_ObjectSelector.cls

Doesn't that call need to be updated since that method is deprecated in fflib_QueryFactory?

But I guess you are right, I can just get the configured Query Factory via newQueryFactory() method from Selector and call the methods from QueryFactory themselves.

from fflib-apex-common.

phyopine-gscs avatar phyopine-gscs commented on August 14, 2024

@afawcett So, to continue on what I was saying before, on very hack-ish way I can add public method like that in fflib_SObjectSelector.

  public fflib_QueryFactory addQueryFactorySubselect(fflib_QueryFactory parentQueryFactory, Boolean includeSelectorFields, String relationshipName)
    {       
        fflib_QueryFactory subSelectQueryFactory = 
            parentQueryFactory.subselectQuery(relationshipName);
        return configureQueryFactory(
            subSelectQueryFactory, 
            m_enforceCRUD, 
            m_enforceFLS, 
            includeSelectorFields);
    }

To use your sample example, following method call will become

public List<Opportunity> selectByIdWithProducts(Set<ID> idSet)
    {
        fflib_QueryFactory opportunitiesQueryFactory = newQueryFactory();

        fflib_QueryFactory lineItemsQueryFactory = 
            new OpportunityLineItemsSelector().
                addQueryFactorySubselect(opportunitiesQueryFactory);

something like this after the changes...

public List<Opportunity> selectByIdWithProducts(Set<ID> idSet)
    {
        fflib_QueryFactory opportunitiesQueryFactory = newQueryFactory();

        fflib_QueryFactory lineItemsQueryFactory = 
            new OpportunityLineItemsSelector().
                addQueryFactorySubselect(opportunitiesQueryFactory,true,'OpportunityLineItems');

Thoughts?

from fflib-apex-common.

afawcett avatar afawcett commented on August 14, 2024

Sorry for the delay, yes that looks great. Can you do a PR?

from fflib-apex-common.

phyopine-gscs avatar phyopine-gscs commented on August 14, 2024

Hi @afawcett , sure thing. Will do that.

Happy Holidays!

from fflib-apex-common.

afawcett avatar afawcett commented on August 14, 2024

👍

from fflib-apex-common.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.