Should statements passed to Query be read-only?

Is there an expectation that SQL statements passed to DB.Query, Conn.Query, etc. from database/sql are read-only, i.e. don’t modify the state of the database? The word “query” suggests that kind of expectation, but there are SQL constructs that return rows while also modifying the database, like DELETE FROM ... RETURNING ... in SQLite (and also PostgreSQL, I think?), and it would seem that the only way to run these statements against the database/sql interfaces would be using Query.

As far as I remember, you have to use *.Query for everything that returns data from the tables.

*.Exec for everything that returns “affected column” count.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.