Chaosthebot / Chaos

A social coding experiment that updates its own code democratically.
http://chaosthebot.com
MIT License
2.44k stars 210 forks source link

Generalize get_or_create to just use the primary key when possible #531

Closed PlasmaPower closed 7 years ago

PlasmaPower commented 7 years ago

Fixes #527 (hopefully). Ideally get_or_create would have an update field which would be like defaults except it would update the record if it did exist. This should work for now though.

PlasmaPower commented 7 years ago

@rudehn Thoughts?

~Edit: marking as WIP until @rudehn responds.~

rudehn commented 7 years ago

Looks good to me

chaosbot commented 7 years ago

:white_check_mark: PR passed with a vote of 10 for and 0 against, a weighted total of 10.0 and a threshold of 6.0, and a current meritocracy review.

See merge-commit bf8ab9120c447d5b5c8ca11b69ed2e7b44fa43f9 for more details.

rudehn commented 7 years ago

Ideally get_or_create would have an update field which would be like defaults except it would update the record if it did exist.

Look into the upsert command. This is insert_or_update. You might need to check database compatibility though

PlasmaPower commented 7 years ago

I think SQLite and MySql are good, so it should be fine for our use.