Skip to content

Commit 13adddd

Browse files
committed
various small but important fixes
1 parent 90e68de commit 13adddd

File tree

8 files changed

+35
-490
lines changed

8 files changed

+35
-490
lines changed

packages/core/src/db/schema/entities/issue.sql.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import {
88
text,
99
} from "drizzle-orm/pg-core";
1010

11-
import type { StateSubmenuValue } from "@/constants/search.constant";
12-
1311
import { getBaseColumns, timestamptz } from "../base.sql";
1412
import type { AggregateReactions, TopCommenters } from "../shared";
1513
import { type Author } from "../shared";
@@ -77,14 +75,19 @@ export const issuesRelations = relations(issueTable, ({ many }) => ({
7775
issuesToLabels: many(issuesToLabels),
7876
}));
7977

80-
export const convertToIssueStateSql = (state: StateSubmenuValue) => {
78+
export const convertToIssueStateSql = (state: string) => {
79+
state = state.toLowerCase();
8180
switch (state) {
8281
case "open":
8382
return eq(issueTable.issueState, "OPEN");
8483
case "closed":
8584
return eq(issueTable.issueState, "CLOSED");
8685
case "all":
8786
return sql`true`;
87+
default:
88+
// actually has small chance of occurring
89+
// if inputs were not validated in schema.input
90+
throw new Error(`Invalid state: ${state}`);
8891
}
8992
};
9093

0 commit comments

Comments
 (0)