diff --git a/src/main/resources/db/insert_weather_table.sql b/src/main/resources/db/insert_weather_table.sql index fc4ed35..9f7f939 100644 --- a/src/main/resources/db/insert_weather_table.sql +++ b/src/main/resources/db/insert_weather_table.sql @@ -2,17 +2,17 @@ INSERT INTO weather (dateTime, city, tempMax, tempMin, tempAvg, precipitation, w VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT (city, dateTime) DO UPDATE SET - tempMax = excluded.tempMax, - tempMin = excluded.tempMin, - tempAvg = excluded.tempAvg, - precipitation = excluded.precipitation, - windAvg = excluded.windAvg, - windMax = excluded.windMax, - visibilityMin = excluded.visibilityMin, - visibilityAvg = excluded.visibilityAvg, - snowAvg = excluded.snowAvg, - atmPressure = excluded.atmPressure, - dewPoint = excluded.dewPoint, - humidity = excluded.humidity, - sunDuration = excluded.sunDuration, - phenomena = excluded.phenomena; \ No newline at end of file + tempMax = COALESCE(excluded.tempMax, weather.tempMax), + tempMin = COALESCE(excluded.tempMin, weather.tempMin), + tempAvg = COALESCE(excluded.tempAvg, weather.tempAvg), + precipitation = COALESCE(excluded.precipitation, weather.precipitation), + windAvg = COALESCE(excluded.windAvg, weather.windAvg), + windMax = COALESCE(excluded.windMax, weather.windMax), + visibilityMin = COALESCE(excluded.visibilityMin, weather.visibilityMin), + visibilityAvg = COALESCE(excluded.visibilityAvg, weather.visibilityAvg), + snowAvg = COALESCE(excluded.snowAvg, weather.snowAvg), + atmPressure = COALESCE(excluded.atmPressure, weather.atmPressure), + dewPoint = COALESCE(excluded.dewPoint, weather.dewPoint), + humidity = COALESCE(excluded.humidity, weather.humidity), + sunDuration = COALESCE(excluded.sunDuration, weather.sunDuration), + phenomena = COALESCE(NULLIF(excluded.phenomena, ARRAY[]::text[]), weather.phenomena); \ No newline at end of file