mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Fix unsupported date_part() in CrDB (#16461)
This commit is contained in:
@@ -10,35 +10,35 @@ const parseLocaltime = (columnType?: string) => {
|
||||
|
||||
export class FnHelperPostgres extends FnHelper {
|
||||
year(table: string, column: string, options: FnHelperOptions): Knex.Raw {
|
||||
return this.knex.raw(`DATE_PART('year', ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
return this.knex.raw(`EXTRACT(YEAR FROM ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
}
|
||||
|
||||
month(table: string, column: string, options: FnHelperOptions): Knex.Raw {
|
||||
return this.knex.raw(`DATE_PART('month', ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
return this.knex.raw(`EXTRACT(MONTH FROM ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
}
|
||||
|
||||
week(table: string, column: string, options: FnHelperOptions): Knex.Raw {
|
||||
return this.knex.raw(`DATE_PART('week', ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
return this.knex.raw(`EXTRACT(WEEK FROM ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
}
|
||||
|
||||
day(table: string, column: string, options: FnHelperOptions): Knex.Raw {
|
||||
return this.knex.raw(`DATE_PART('day', ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
return this.knex.raw(`EXTRACT(DAY FROM ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
}
|
||||
|
||||
weekday(table: string, column: string, options: FnHelperOptions): Knex.Raw {
|
||||
return this.knex.raw(`DATE_PART('dow', ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
return this.knex.raw(`EXTRACT(DOW FROM ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
}
|
||||
|
||||
hour(table: string, column: string, options: FnHelperOptions): Knex.Raw {
|
||||
return this.knex.raw(`DATE_PART('hour', ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
return this.knex.raw(`EXTRACT(HOUR FROM ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
}
|
||||
|
||||
minute(table: string, column: string, options: FnHelperOptions): Knex.Raw {
|
||||
return this.knex.raw(`DATE_PART('minute', ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
return this.knex.raw(`EXTRACT(MINUTE FROM ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
}
|
||||
|
||||
second(table: string, column: string, options: FnHelperOptions): Knex.Raw {
|
||||
return this.knex.raw(`DATE_PART('second', ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
return this.knex.raw(`EXTRACT(SECOND FROM ??.??${parseLocaltime(options?.type)})`, [table, column]);
|
||||
}
|
||||
|
||||
count(table: string, column: string, options?: FnHelperOptions): Knex.Raw {
|
||||
|
||||
Reference in New Issue
Block a user