Skip to content

Commit

Permalink
Updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
paustint committed Oct 2, 2019
1 parent 4d8520f commit e0a5b92
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions docs/src/components/parse-soql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ interface IParseSoqlState {
soql: string;
format: boolean;
formatOptions: FormatOptions;
parseDuration: number;
}

export class ParseSoql extends React.Component<IParseSoqlProps, IParseSoqlState> {
constructor(props: IParseSoqlProps) {
super(props);

const parsedSoql = props.soql ? parseQuery(props.soql) : undefined;

const start = performance.now();
const parsedSoql = props.soql ? parseQuery(props.soql, {allowApexBindVariables: true}) : undefined;
const end = performance.now();

const composedQuery = parsedSoql ? composeQuery(parsedSoql) : '';

this.state = {
Expand All @@ -38,6 +42,7 @@ export class ParseSoql extends React.Component<IParseSoqlProps, IParseSoqlState>
fieldSubqueryParensOnOwnLine: true,
whereClauseOperatorsIndented: false,
},
parseDuration: parsedSoql ? end - start : -1,
};
}

Expand All @@ -54,7 +59,7 @@ export class ParseSoql extends React.Component<IParseSoqlProps, IParseSoqlState>
};

public isValid = (query: string) => {
return isQueryValid(query);
return isQueryValid(query, {allowApexBindVariables: true});
};

public getValidMessage = () => {
Expand All @@ -67,18 +72,24 @@ export class ParseSoql extends React.Component<IParseSoqlProps, IParseSoqlState>

public parseQuery = (query?: string, format?: boolean, formatOptions?: FormatOptions) => {
try {
const parsedSoql: Query = parseQuery(query || this.state.soql);

const start = performance.now();
const parsedSoql: Query = parseQuery(query || this.state.soql, {allowApexBindVariables: true});
const end = performance.now();

const composedQuery: string = composeQuery(parsedSoql, {
format: typeof format === 'boolean' ? format : this.state.format,
formatOptions: formatOptions || this.state.formatOptions,
});
this.setState({
parsedSoql: JSON.stringify(parsedSoql, null, 4),
composedQuery,
parseDuration: end - start
});
} catch (ex) {
this.setState({
parsedSoql: ex.message,
parseDuration: -1,
});
}
};
Expand Down Expand Up @@ -134,8 +145,9 @@ export class ParseSoql extends React.Component<IParseSoqlProps, IParseSoqlState>
<span>
Parsed Query -
<small style={{ marginLeft: 5 }}>
<code>parseQuery(soqlQuery);</code>
<code>parseQuery(soqlQuery, {`{allowApexBindVariables: true}`});</code>
</small>
{this.state.parseDuration > 0 && (<div><small>Parsed in {this.state.parseDuration.toFixed(2)} milliseconds</small></div>)}
</span>
}
lang="json"
Expand Down

0 comments on commit e0a5b92

Please sign in to comment.