mpope9 / nba-sql

:basketball: An application to build an NBA database backed by MySQL, Postgres, or SQLite
Apache License 2.0
171 stars 20 forks source link

Use `on_conflict_replace` with peewee #76

Closed alpacafondue closed 11 months ago

alpacafondue commented 2 years ago

With the Windows client, constraint errors can occur when running multiple seasons.on_conflict_replace should resolve this I believe in the event a constraint is violated.

mpope9 commented 2 years ago

@alpacafondue Interesting, I haven't run into this issue but I use the Windows client only to test the release. This error is reproducible by selecting multiple seasons from the list and running the client? Is this against Postgres?

alpacafondue commented 2 years ago

Yea, this was against Postgres when running multiple seasons for player_season. But I could also see the constraint violation happening for other table updates where the row already exists (e.g. running a season again).

mpope9 commented 2 years ago

Ah I see. Yes, running overlapping seasons isn't really supported at the moment. So this was specifically on the seasons table? Adding a ignore/replace there shouldn't be too hard.

I can't remember, is there an option in the Windows client to update the current season? I added a prototype back in December for a subset of tables, but I can't recall if I integrated the option into the GUI.

alpacafondue commented 2 years ago

Right, I don't believe that option is available in the GUI from what I could tell.

mpope9 commented 1 year ago

Possible fix, will test on player_season. https://github.com/mpope9/nba-sql/pull/81