feat(core): Optionally return updated/upserted Data Table rows (no-changelog) (#18735)

This commit is contained in:
Jaakko Husso
2025-08-26 11:50:13 +03:00
committed by GitHub
parent 1e58e24400
commit 8defb2b17c
9 changed files with 602 additions and 145 deletions

View File

@@ -216,19 +216,25 @@ export function normalizeRows(rows: DataStoreRows, columns: DataStoreColumn[]) {
}
}
if (type === 'date' && value !== null && value !== undefined) {
// Convert date objects or strings to ISO string
// Convert date objects or strings to dates in UTC
let dateObj: Date | null = null;
if (value instanceof Date) {
dateObj = value;
} else if (typeof value === 'string' || typeof value === 'number') {
} else if (typeof value === 'string') {
// sqlite returns date strings without timezone information, but we store them as UTC
const parsed = new Date(value.endsWith('Z') ? value : value + 'Z');
if (!isNaN(parsed.getTime())) {
dateObj = parsed;
}
} else if (typeof value === 'number') {
const parsed = new Date(value);
if (!isNaN(parsed.getTime())) {
dateObj = parsed;
}
}
normalized[key] = dateObj ? dateObj.toISOString() : value;
normalized[key] = dateObj ?? value;
}
}
return normalized;
@@ -259,9 +265,3 @@ export function normalizeValue(
export function getPlaceholder(index: number, dbType: DataSourceOptions['type']): string {
return dbType.includes('postgres') ? `$${index}` : '?';
}
export function buildColumnTypeMap(
columns: Array<{ name: string; type: string }>,
): Record<string, string> {
return Object.fromEntries(columns.map((col) => [col.name, col.type]));
}