Giter VIP home page Giter VIP logo

apex-query-builder's People

Contributors

4an70m avatar aranwe avatar djartem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

apex-query-builder's Issues

Order logic does not work with multi-digit conditions

The following query works as expected:

new QueryBuilder(Account.class)
	.addField(Account.Name)
	
	.addConditions()
	.add(new QueryBuilder.SimpleCondition('Name = \'acc1\''))
	.add(new QueryBuilder.SimpleCondition('Name = \'acc2\''))
	.add(new QueryBuilder.SimpleCondition('Name = \'acc3\''))
	.add(new QueryBuilder.SimpleCondition('Name = \'acc4\''))
	(...)
	.add(new QueryBuilder.SimpleCondition('Name = \'acc12\''))
	.setConditionOrder('1 OR 2 OR 12')
	.preview();
Name = 'acc1' OR Name = 'acc2' OR Name = 'acc12'

, but if we change the order:

	.setConditionOrder('12 OR 1 OR 2')

, the query gets malformed:

Name = 'acc1'Name = 'acc2' OR 1 OR 2

, since 12 is replaced by {1}{2} in bracketConditions (and the subsequent 1 and 2 are left unbracketed ).

Name field in sub-query is removed

create a simple query select id, name from account

add a sub query to an object which also has Name as a field
( Id, Name from xxx__r )

expect both sobjects to have name field returned
observed the Name field is removed from the subquery

Datetime support

Currently no datetime is supported.

Something like this would be appreciated.
Also date literals would be great.

https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm

private static final String GMT_DATE_FORMAT = 'yyyy-MM-dd\'T\'HH:mm:ss\'Z\'';

public class CompareCondition extends FieldCondition {
        ....
        public Condition lt(Datetime fieldValue) {
            this.formedCondition = this.fieldName + ' < ' + fieldValue.formatGmt(GMT_DATE_FORMAT);
            return this;
        }

        public Condition gt(Datetime fieldValue) {
            this.formedCondition = this.fieldName + ' > ' + fieldValue.formatGmt(GMT_DATE_FORMAT);
            return this;
        }

        public Condition lte(Datetime fieldValue) {
            this.formedCondition = this.fieldName + ' <= ' + fieldValue.formatGmt(GMT_DATE_FORMAT);
            return this;
        }

        public Condition gte(Datetime fieldValue) {
            this.formedCondition = this.fieldName + ' >= ' + fieldValue.formatGmt(GMT_DATE_FORMAT);
            return this;
        }
}

Implicit AND clause on addConditions() with multiple conditions

Current behaviour:

new QueryBuilder(Account.class)
        .addConditions()
        .add(new QueryBuilder.SimpleCondition('Name = \'Test\'')
        .add(new QueryBuilder.SimpleCondition('Field2 = \'Test\'')
        .endConditions()
        .toString();

// returns SELECT Id FROM Account WHERE Name = 'Test'

Expected behaviour:

 SELECT Id FROM Account WHERE Name = 'Test' AND Field2 = 'Test'

If there is no explicit ordering set I think it should implicitly join all Conditions with an AND clause

I have it implemented -> should I send PR?

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.