-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Background
The PolicyDBClient
struct uses composition to expose all SQLC generated queries as functions callable from that struct. While this does simplify interaction with those functions, it also has unintended consequences:
-
Since the service layer uses the
PolicyDBClient
struct to make calls to the DB layer methods, a developer could accidentally bypass the DB layer and call a SQLC generated method directly that was never meant to be exposed to the service layer. DB layer methods handle the appropriate transformations from SQLC generated structs to policy objects, and thus should be the only DB-specific methods called from the service layer. -
Bloated intellisense exacerbates the first issue, as it's not entirely clear to the developer which method is SQLC generated vs one that was intentionally written in the DB layer.
Acceptance Criteria
- Only intentionally written DB layer methods are exposed by the
PolicyDBClient
- All unit and integration tests continue to pass
Possible solutions that need further investigation:
- Update all SQLC query names to use lowercase for the leading character to tell Go not to expose them as public
- Refactor the
PolicyDBClient
to no longer use composition with theQueries
struct and use global variable for Queries that is only referenced within thedb
package - Mix of 1 and/or 2 OR do both?