volatiletech / sqlboiler

Generate a Go ORM tailored to your database schema.
BSD 3-Clause "New" or "Revised" License
6.7k stars 542 forks source link

Type safe updates #761

Open rakeshbala opened 4 years ago

rakeshbala commented 4 years ago

Are type-safe updates possible? So far I've seen only an UpdateAll method which takes a map[string] interface{} (as opposed to the type-specific columns in the where clauses).

Apologies if I missed something in the documentation.

rakeshbala commented 4 years ago

I realized that I can do a find and then call Update on the model struct. So that is a workaround. That is still 2 queries I guess and also wouldn't work when I want to update a bunch of rows.

Changing this issue to a feature request to add type-safe columns to UpdateAll call. 🙂

aarondl commented 4 years ago

Yep. Currently there's no way to do this. I'm not sure how you would accomplish it either (otherwise we probably would have done it!).

Perhaps you could pass in a single model to the UpdateAll call? And then also a boil.Columns?