openlawlibrary / stelae

Preservation, Authentication, Access
GNU Affero General Public License v3.0
7 stars 1 forks source link

Use `sqlx::query_file_as!` macro #35

Open n-dusan opened 4 months ago

n-dusan commented 4 months ago

The sql statements would go into a separate sql file. That would help us with syntax highlighting, keeping things more sane, etc.

Have you seen the sqlx::query_file_as! macro? https://github.com/launchbadge/sqlx/tree/main/examples/postgres/files It allows you to keep SQL statements in .sql files. I think it's something to bear in mind as SQL statements get bigger. It's obviously not critical, but I think being able to write SQL in actual .sql files helps keep SQL sane, because then we get things like editor syntax highlighting and linters like https://github.com/sqlfluff/sqlfluff

_Originally posted by @tombh in https://github.com/openlawlibrary/stelae/pull/33#discussion_r1595470996_