(
field: string,
unit: string,
timezone: string
)
| 75 | } |
| 76 | |
| 77 | protected getDateQuery( |
| 78 | field: string, |
| 79 | unit: string, |
| 80 | timezone: string |
| 81 | ): Prisma.Sql { |
| 82 | if (this.shouldUseClickhouse()) { |
| 83 | return this.getClickHouseDateQuery(field, unit, timezone); |
| 84 | } |
| 85 | |
| 86 | // Check if unit exists in POSTGRESQL_DATE_FORMATS before using it |
| 87 | if (!(unit in POSTGRESQL_DATE_FORMATS)) { |
| 88 | throw new Error(`Invalid date unit: ${unit}`); |
| 89 | } |
| 90 | |
| 91 | return sql`to_char(date_trunc(${unit}, ${raw(field)} at time zone ${timezone}), '${raw(POSTGRESQL_DATE_FORMATS[unit as keyof typeof POSTGRESQL_DATE_FORMATS])}')`; |
| 92 | } |
| 93 | |
| 94 | protected getClickHouseDateQuery( |
| 95 | field: string, |
no outgoing calls
no test coverage detected