pavelfilippi / weather-monitor

MIT License
1 stars 0 forks source link

Cannot delete weather station with weather condition data #17

Open pavelfilippi opened 1 year ago

pavelfilippi commented 1 year ago

Description

Weather station cannot be removed if there are data linked in weather_real_time table.

Steps to reproduce

1, Create weather station 2, Insert related weather data 3, Remove weather station

{
  "data": null,
  "errors": [
    {
      "message": "(sqlalchemy.dialects.postgresql.asyncpg.IntegrityError) <class 'asyncpg.exceptions.NotNullViolationError'>: null value in column \"station_id\" of relation \"_hyper_1_1_chunk\" violates not-null constraint\nDETAIL:  Failing row contains (2022-11-24 11:01:37.123, null, 0, 0, 0, 0).\n[SQL: UPDATE weather_real_time SET station_id=%s WHERE weather_real_time.time = %s]\n[parameters: (None, datetime.datetime(2022, 11, 24, 11, 1, 37, 123000))]\n(Background on this error at: https://sqlalche.me/e/14/gkpj)",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "removeWeatherStation"
      ]
    }
  ]
}

Desired behavior

Weather station should be possible to remove and still keep weather condition data.

pavelfilippi commented 1 year ago

Partially fixed in https://github.com/pavelfilippi/weather-monitor/pull/18. Users can now remove weather station, but it cascades to related weather conditions.