You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+86-8Lines changed: 86 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,12 @@ With this change, the data model was reviewed and analyzed, and there are some s
10
10
11
11
#### Bundle Size
12
12
13
-
To compare the bundle size, the following small program was written and then compiled using the default configuration of webpack, and the output bundle was compared.
13
+
To compare the bundle size, the following small program was written and then compiled using the default configuration of webpack, and the resulting webpack bundle was compared to determine the full size of the library.
14
+
15
+
Minified, uncompressed:
14
16
15
17
- Version 1.x: **545kb**
16
-
- Version 2.0: **197kb**
18
+
- Version 2.0: **207kb**
17
19
18
20
```javascript
19
21
var soqlParser =require('soql-parser-js');
@@ -26,11 +28,24 @@ console.log('soql', soql);
26
28
27
29
#### Benchmarks
28
30
29
-
Here is an example benchmark of parsing all the unit tests 1,000 times
31
+
Performance testing was done by iterating the unit tests 60K times, here are the results:
@@ -44,9 +59,9 @@ NEW PARSER: ~2.25 seconds for 60K parses
44
59
-`TRUE`, `FALSE`, and all functions except those listed below will always be returned in uppercase, regardless of case of input.
45
60
-**Exceptions**:
46
61
-`toLabel`, `convertTimezone`, `convertCurrency` will always be in camelCase.
47
-
- Added new available types for `DateLiteral` and `DateNLiteral`.
62
+
- Added types for `DateLiteral` and `DateNLiteral` values. If you are using TypeScript, you can utilize these types.
48
63
- A new `LiteralType` value was added for `APEX_BIND_VARIABLE`.
49
-
- When composing functions in a where clause or group by clause, the `rawValue` will be preferred (if exists) (no change here), but if rawValue is not provided, then the function will be composed using the `functionName` and `parameters`.
64
+
- When composing functions in a where clause or group by clause, the `rawValue` will be preferred (if it exists) (no change here), but if rawValue is not provided, then the function will be composed using the `functionName` and `parameters`.
50
65
- A new `LiteralType` value was added for `INTEGER_WITH_CURRENCY_PREFIX` and `DECIMAL_WITH_CURRENCY_PREFIX`. e.x. `USD500.01`
- Added support for `usingScope` - https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_using_scope.htm?search_text=format()
Copy file name to clipboardExpand all lines: README.md
+67-22Lines changed: 67 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,11 @@
12
12
13
13
1. Parse SOQL queries into a common `Query` data structure.
14
14
2. Compose a `Query` data structure back into a SOQL query.
15
-
3. Validate a query to check if the syntax is valid. (Note: even if a query is valid, it might still be invalid based on your org configuration)
15
+
3. Validate a query to check if the syntax is valid. (Note: even if a query is returned as valid, it might still be invalid based on your Salesforce configuration)
16
16
17
-
This library uses [Chevrotain](https://github.com/SAP/chevrotain) to parse queries. Prior to version 2.0.0, [antlr4](https://github.com/antlr/antlr4) was used. The move to Chevrotain provided a 35% performance improvement and resulted in a 36% decrease in bundle size. :tada:
17
+
This library uses [Chevrotain](https://github.com/SAP/chevrotain) to parse queries. Prior to version 2.0.0, [antlr4](https://github.com/antlr/antlr4) was used. The move to Chevrotain provided a significant performance increase and decrease in bundle size. :tada:
18
+
19
+
Migrating from version 1 to version 2? [Check out the changelog](CHANGELOG.md#200) for a full list of changes.
18
20
19
21
Want to try it out? [Check out the demo](https://paustint.github.io/soql-parser-js/).
20
22
@@ -39,24 +41,32 @@ isQueryValid('SELECT Id Foo FROM Baz'); // false
| getField | Convenience method to construct fields in the correct format when using `composeQuery()`. Look in the data models section below for the structure of `ComposeFieldInput`. | input: `string | ComposeFieldInput` |
52
+
| isSubquery | Returns `true` if the data passed in is a subquery. | query: `Query | Subquery` |
53
+
| getFlattenedFields | Flatten a Salesforce record based on the parsed SOQL Query. | soql: Query<br> config?: SoqlComposeConfig |
| format | boolean | Apply formatting the the composed query. This will result in a multi-line soql statement. | FALSE | TRUE |
56
-
| formatOptions | FormatOptions | Options to apply to the formatter. | FALSE ||
57
-
| autoCompose | boolean | If you need to compose just part of a query, you can create your own instance of the Compose class and set this to false, then call any methods that you need to just for what you would like to turn into a SOQL query. | FALSE | TRUE |
58
-
| useRawValueForFn | boolean | When composing WHERE/GROUP BY functions, prefer the `rawValue` property instead of using `functionName` and `parameters` to compose the query. | FALSE | TRUE |
59
-
| logging | boolean | Print out logging statements to the console about the format operation. | FALSE | FALSE |
| format | boolean | Apply formatting the the composed query. This will result in a multi-line soql statement. | FALSE | TRUE |
67
+
| formatOptions | FormatOptions | Options to apply to the formatter. | FALSE ||
68
+
| autoCompose | boolean | If you need to compose just part of a query, you can create your own instance of the Compose class and set this to false, then call any methods that you need to just for what you would like to turn into a SOQL query. | FALSE | TRUE |
69
+
| logging | boolean | Print out logging statements to the console about the format operation. | FALSE | FALSE |
60
70
61
71
**FormatOptions**
62
72
@@ -65,7 +75,7 @@ isQueryValid('SELECT Id Foo FROM Baz'); // false
65
75
| numIndent | number | The number of tab characters to indent. | FALSE | 1 |
66
76
| fieldMaxLineLength | number | The number of characters that the fields should take up before making a new line. Set this to 1 to have every field on its own line. | FALSE | 60 |
67
77
| fieldSubqueryParensOnOwnLine | boolean | If true, the opening and closing parentheses will be on their own line for subqueries. | FALSE | TRUE |
68
-
| whereClauseOperatorsIndented | boolean | If true, indents the where clause operators| FALSE | FALSE |
78
+
| whereClauseOperatorsIndented | boolean | If true, indents the where clause operators.| FALSE | FALSE |
69
79
| logging | boolean | Print out logging statements to the console about the format operation. | FALSE | FALSE |
@@ -158,7 +167,7 @@ These examples show building your own Query object with the minimum required fie
158
167
159
168
Some utility methods have been provided to make it easier to build the field data structures.
160
169
161
-
**Note:** Some operators may be converted to upper case (e.x. NOT, AND)
170
+
**Note:** Some operators may be converted to uppercase (e.x. NOT, AND)
162
171
163
172
**Note:** There are a number of fields populated on the Query object when `parseQuery()` is called that are not required to compose a query. Look at the examples below and the comments in the data model for more information.
164
173
@@ -369,12 +378,14 @@ WHERE Name LIKE 'a%'
369
378
The following utility functions are available:
370
379
371
380
1.`getField(input: string | ComposeFieldInput)`
372
-
1. Convenience method to construct fields in the correct data format. See example usage in the Compose example.
381
+
1. Convenience method to construct fields in the correct format. See data model below for the various input types as well as example usage in the Compose examples above.
382
+
2. returns one of the following data structures: `SoqlModels.FieldFunctionExpression | SoqlModels.Field | SoqlModels.FieldRelationship | SoqlModels.FieldSubquery | SoqlModels.FieldTypeOf`.
373
383
2.`isSubquery(query: Query | Subquery)`
374
-
1. Returns true if the data passed in is a subquery
384
+
1. Returns `true` if the data passed in is a subquery
375
385
3.`getFlattenedFields(query: Query)`
376
386
1. Flatten a Salesforce record based on the parsed SOQL Query. this is useful if you have relationships in your query and want to show the results in a table, using `.` dot notation for the relationship field headings.
377
-
2. Refer to `tests/publicUtils.spec.ts` for usage examples.
387
+
2. Returns an array of strings.
388
+
3. Refer to `tests/publicUtils.spec.ts` for usage examples.
rawValue?:string; //only used for compose fields if useRawValueForFn=true. Should be formatted like this: Count(Id)
567
-
functionName?:string; //only used for compose fields if useRawValueForFn=false, not used for compose, will be populated if SOQL is parsed
577
+
rawValue?:string; //This is the entire text of the function, such as Count(Id). When composing a query, if this is populated this will be used to build output SOQL query.
578
+
functionName?:string; //When composing a query, if rawValue is undefined/null this will be used to build the SOQL query.
568
579
alias?:string;
569
-
parameters?: (string|FunctionExp)[]; //only used for compose fields if useRawValueForFn=false, not used for compose, will be populated if SOQL is parsed
580
+
parameters?: (string|FunctionExp)[]; //When composing a query, if rawValue is undefined/null this will be used to build the SOQL query.
570
581
isAggregateFn?:boolean; // not used for compose, will be populated if SOQL is parsed
All contributions are welcome on the project. Please read the [contribution guidelines](https://github.com/paustint/soql-parser-js/blob/master/CONTRIBUTING.md).
0 commit comments