Skip to content

Provide additional type information in WHERE clause #51

@paustint

Description

@paustint
  • Feature
  • Bug Request

Description

When parsing WHERE clauses, we should store indicators of the field type if possible. It would be useful to know if a date literal is used or if the type is a string or some other type so that consumers can more reliably build a compose object to be parsed.

Example:
This query has multiple data types where some need to be quoted and others do not.
SELECT Id FROM Account WHERE dateField != '2018-10-03' AND dateField < LAST_WEEK AND isDeleted = false AND someOTherField = 'someVal'

TODO

  • Add type information for fields
  • Add type information for date literals and date n literals
  • having clause updated with literal types
  • update unit tests
    • confirm that any new tests are added for full coverage
  • update changelog
  • array values in the WHERE clause don't fit the data model for LiteralType - may need to implement breaking change or find some other way to represent the types for these fields
    example:
{
    testCase: 34,
    soql: `SELECT Id FROM Account WHERE Foo IN ('1', '2', '3') OR Bar IN (1, 2, 3) OR Baz IN (101.00, 102.50) OR Bam IN ('FOO', null)`,
    output: {
      fields: [
        {
          text: 'Id',
        },
      ],
      subqueries: [],
      sObject: 'Account',
      where: {
        left: {
          field: 'Foo',
          operator: 'IN',
          value: ["'1'", "'2'", "'3'"],
          literalType: 'STRING',
        },
        operator: 'OR',
        right: {
          left: {
            field: 'Bar',
            operator: 'IN',
            value: ['1', '2', '3'],
            literalType: 'INTEGER',
          },
          operator: 'OR',
          right: {
            left: {
              field: 'Baz',
              operator: 'IN',
              value: ['101.00', '102.50'],
              literalType: 'DECIMAL',
            },
            operator: 'OR',
            right: {
              left: {
                field: 'Bam',
                operator: 'IN',
                value: ["'FOO'", 'null'],
                literalType: 'NULL',
              },
            },
          },
        },
      },
    },
  },

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestquestionFurther information is requested

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions