aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Shulaev <ddrone@google.com>2023-02-28 10:09:30 +0000
committerAndrew Shulaev <ddrone@google.com>2023-02-28 10:11:28 +0000
commitf0db0b9f9a5f4862c3f00e00ac9fce921b3da9eb (patch)
tree7175d0c372d201b3d93613e4d792c1fbca34a2c6
parent1eaed300ee5bca268bc5e59def249591f460820c (diff)
downloadperfetto-f0db0b9f9a5f4862c3f00e00ac9fce921b3da9eb.tar.gz
Rename `where` to `filters`
Using `where` as a name seems to trip up JS formatter we use (see the indentation in the definition of SQLConstraints, it gets even worse in highly nested code). Rename the field to `filters` to avoid triggering the problem. Change-Id: Icc7521468460496ed9a5f2a1bcf218d530f40a23
-rw-r--r--ui/src/frontend/sql_utils.ts6
-rw-r--r--ui/src/frontend/sql_utils_unittest.ts4
-rw-r--r--ui/src/frontend/thread_state.ts2
3 files changed, 6 insertions, 6 deletions
diff --git a/ui/src/frontend/sql_utils.ts b/ui/src/frontend/sql_utils.ts
index ff6e200ea..422e70fd1 100644
--- a/ui/src/frontend/sql_utils.ts
+++ b/ui/src/frontend/sql_utils.ts
@@ -21,7 +21,7 @@ interface OrderClause {
// Interface for defining constraints which can be passed to a SQL query.
export interface SQLConstraints {
- where?: string[];
+ filters?: string[];
orderBy?: OrderClause[];
limit?: number;
}
@@ -30,8 +30,8 @@ export interface SQLConstraints {
// SQL query.
export function constraintsToQueryFragment(c: SQLConstraints): string {
const result: string[] = [];
- if (c.where && c.where.length > 0) {
- result.push(`WHERE ${c.where.join(' and ')}`);
+ if (c.filters && c.filters.length > 0) {
+ result.push(`WHERE ${c.filters.join(' and ')}`);
}
if (c.orderBy && c.orderBy.length > 0) {
const orderBys = c.orderBy.map((clause) => {
diff --git a/ui/src/frontend/sql_utils_unittest.ts b/ui/src/frontend/sql_utils_unittest.ts
index d8e35bad6..0e5dc7688 100644
--- a/ui/src/frontend/sql_utils_unittest.ts
+++ b/ui/src/frontend/sql_utils_unittest.ts
@@ -21,7 +21,7 @@ function normalize(s: string): string {
test('constraintsToQueryFragment: where', () => {
expect(normalize(constraintsToQueryFragment({
- where: ['ts > 1000', 'dur != 0'],
+ filters: ['ts > 1000', 'dur != 0'],
}))).toEqual('WHERE ts > 1000 and dur != 0');
});
@@ -37,7 +37,7 @@ test('constraintsToQueryFragment: limit', () => {
test('constraintsToQueryFragment: all', () => {
expect(normalize(constraintsToQueryFragment({
- where: ['id != 1'],
+ filters: ['id != 1'],
orderBy: [{fieldName: 'ts'}],
limit: 1,
}))).toEqual('WHERE id != 1 ORDER BY ts LIMIT 1');
diff --git a/ui/src/frontend/thread_state.ts b/ui/src/frontend/thread_state.ts
index 4513c5583..1a4f558b5 100644
--- a/ui/src/frontend/thread_state.ts
+++ b/ui/src/frontend/thread_state.ts
@@ -125,7 +125,7 @@ export async function getThreadStateFromConstraints(
export async function getThreadState(
engine: EngineProxy, id: number): Promise<ThreadState|undefined> {
const result = await getThreadStateFromConstraints(engine, {
- where: [`id=${id}`],
+ filters: [`id=${id}`],
});
if (result.length > 1) {
throw new Error(`thread_state table has more than one row with id ${id}`);