sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

"Unsafe" as a backwards compat method

Open aep opened this issue 4 years ago • 1 comments

Hi,

i'm confused why Unsafe is called unsafe. The naming suggests i'm misunderstanding fundamentally how you're supposed to retain backwards compatibility when adding fields to a database.

Without Unsafe, when adding a field, older database clients that dont know the field yet will fail. So you must first upgrade all clients and THEN migrate, which sounds backwards?

the alternative "correct" solution would be to explicitly name every field in the struct AND the query, but then what's the added benefit over just using stdlib sql?

aep avatar Feb 21 '21 14:02 aep

Lots of applications run migrations up first and then restart the application. SQLs select * from X would fail after it saw any unknown column. I'm also looking for a global configuration to set unsafe always to true without manually calling.Unsafe()

vm-001 avatar Aug 07 '24 13:08 vm-001