mgutz / dat

Go Postgres Data Access Toolkit
Other
612 stars 62 forks source link

Add "ForUpdate" to SelectBuilder? #45

Closed sbowman closed 8 years ago

sbowman commented 8 years ago

It would be nice to have a ForUpdate function in the SelectBuilder for working with transactions and row-level locking.

Or is there another approach I'm missing?

mgutz commented 8 years ago

We predominately use SQL statements so it's never come up. It's easy to add. I prefer a single For method

// For("update")
// For("share")
For(options ...string)

rather than

ForShare(options ...string)
ForUpdate(options ...string)

Thoughts?

sbowman commented 8 years ago

I agree. A For() method would be way more flexible than individual methods.

ghost commented 8 years ago

What's about type safety? From that perspective ForShare / ForUpdate is a better option.

mgutz commented 8 years ago

@alkchr Unfortunately, there are 4 variations of For with options in PG 9.5. Who knows if the PG team will add more in the future. I'd rather not pollute the API surface with every variant.