better deploys
Some checks failed
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Failing after 2m24s

This commit is contained in:
2025-11-24 18:52:52 -08:00
parent 6c6a4ab0d7
commit 2c7fdd1693
3 changed files with 22 additions and 12 deletions

View File

@@ -70,16 +70,19 @@ const USER_DATA_TABLES: Record<string, string> = {
'shopping_trips': 'user_id',
};
type DBValue = string | number | boolean | null | Date | object;
/**
* Generates a SQL INSERT statement for a given row of data.
* @param table The name of the table.
* @param row The data object for the row.
* @returns A formatted SQL INSERT statement string.
*/
function generateInsertStatement(table: string, row: Record<string, any>): string {
function generateInsertStatement(table: string, row: Record<string, DBValue>): string {
const columns = Object.keys(row).map(col => `"${col}"`).join(', ');
const values = Object.values(row).map(val => {
if (val === null) return 'NULL';
if (val instanceof Date) return `'${val.toISOString()}'`; // Handle Date objects
if (typeof val === 'string') return `'${val.replace(/'/g, "''")}'`; // Escape single quotes
if (typeof val === 'object') return `'${JSON.stringify(val).replace(/'/g, "''")}'`; // Handle JSONB
return val;
@@ -162,4 +165,3 @@ async function main() {
}
main();