Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ describe("normaliseQuery", () => {
"SELECT campaign.name FROM campaign LIMIT 10"
);
});

it("will properly handle multiline query statements", () => {
const query = `
SELECT
asset_group.id,
metrics.conversions_value,
metrics.conversions
FROM asset_group_asset
WHERE campaign.advertising_channel_type = 'PERFORMANCE_MAX';
`;

expect(normaliseQuery(query)).toEqual(
"SELECT asset_group.id, metrics.conversions_value, metrics.conversions FROM asset_group_asset WHERE campaign.advertising_channel_type = 'PERFORMANCE_MAX';"
);
});
});

describe("capitaliseFirstLetter", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function toMicros(value: number): number {
* const normalisedQuery = normaliseQuery(gaqlQuery) // "SELECT campaign.name FROM campaign LIMIT 10"
*/
export function normaliseQuery(query: string): string {
return `${query.replace(/\s{2,}/g, " ")}`;
return query.replace(/\s+/g, " ").trim();
}

/**
Expand Down
Loading