|
|
@ -54,6 +54,25 @@ export function validateDateWithUnknownFormat(v: string) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function convertDateFormatByType(query, clientType, dateFormat) { |
|
|
|
|
|
|
|
if (clientType === 'mysql2') { |
|
|
|
|
|
|
|
query = `DATE_FORMAT(${query}, '${convertDateFormat( |
|
|
|
|
|
|
|
dateFormat, |
|
|
|
|
|
|
|
clientType |
|
|
|
|
|
|
|
)}')`;
|
|
|
|
|
|
|
|
} else if (clientType === 'pg') { |
|
|
|
|
|
|
|
query = `TO_CHAR(${query}, '${convertDateFormat(dateFormat, clientType)}')`; |
|
|
|
|
|
|
|
} else if (clientType === 'sqlite3') { |
|
|
|
|
|
|
|
query = `strftime('${convertDateFormat( |
|
|
|
|
|
|
|
dateFormat, |
|
|
|
|
|
|
|
clientType |
|
|
|
|
|
|
|
)}', ${query})`;
|
|
|
|
|
|
|
|
} else if (clientType === 'mssql') { |
|
|
|
|
|
|
|
query = `FORMAT(${query}, '${convertDateFormat(dateFormat, clientType)}')`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return query; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export async function convertDateFormatForConcat( |
|
|
|
export async function convertDateFormatForConcat( |
|
|
|
o, |
|
|
|
o, |
|
|
|
columnIdToUidt, |
|
|
|
columnIdToUidt, |
|
|
@ -71,27 +90,7 @@ export async function convertDateFormatForConcat( |
|
|
|
}) |
|
|
|
}) |
|
|
|
).meta; |
|
|
|
).meta; |
|
|
|
|
|
|
|
|
|
|
|
if (clientType === 'mysql2') { |
|
|
|
return convertDateFormatByType(query, clientType, meta.date_format); |
|
|
|
query = `DATE_FORMAT(${query}, '${convertDateFormat( |
|
|
|
|
|
|
|
meta.date_format, |
|
|
|
|
|
|
|
clientType |
|
|
|
|
|
|
|
)}')`;
|
|
|
|
|
|
|
|
} else if (clientType === 'pg') { |
|
|
|
|
|
|
|
query = `TO_CHAR(${query}, '${convertDateFormat( |
|
|
|
|
|
|
|
meta.date_format, |
|
|
|
|
|
|
|
clientType |
|
|
|
|
|
|
|
)}')`;
|
|
|
|
|
|
|
|
} else if (clientType === 'sqlite3') { |
|
|
|
|
|
|
|
query = `strftime('${convertDateFormat( |
|
|
|
|
|
|
|
meta.date_format, |
|
|
|
|
|
|
|
clientType |
|
|
|
|
|
|
|
)}', ${query})`;
|
|
|
|
|
|
|
|
} else if (clientType === 'mssql') { |
|
|
|
|
|
|
|
query = `FORMAT(${query}, '${convertDateFormat( |
|
|
|
|
|
|
|
meta.date_format, |
|
|
|
|
|
|
|
clientType |
|
|
|
|
|
|
|
)}')`;
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return query; |
|
|
|
return query; |
|
|
|
} |
|
|
|
} |
|
|
|