Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Epic: Migrate Policy SQL database queries to sqlc #1420

Closed
9 of 13 tasks
ryanulit opened this issue Aug 22, 2024 · 1 comment
Closed
9 of 13 tasks

Epic: Migrate Policy SQL database queries to sqlc #1420

ryanulit opened this issue Aug 22, 2024 · 1 comment
Labels
comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry)

Comments

@ryanulit
Copy link
Contributor

ryanulit commented Aug 22, 2024

Problem Statement

Most of our SQL queries are dynamically generated using squirrel to build the queries at runtime. The sqlc library allows you write pure SQL and have Golang code generated for you, and we've had good experiences using this library in COP and elsewhere.

Depends On

Object Queries

Testing Infrastructure

Sqlc Improvements

Background

All of policy in the opentdf/platform was built with a tool called squirrel to write PostgreSQL queries programmatically in Go. A new tool called sqlc to write queries directly in SQL and generate the Go code was identified, tested in COP and proven to be useful, and advocated for by larger companies like ngrok at Gophercon.

Unblocks

Rationale

  • squirrel got us to the initial release of platform v2 in the time needed
  • Squirrel was familiar to our team and not a new technology under a tight time constraint
  • Sqlc was proven out in COP and has already been utilized in policy for kas-registry and the GetAttributesByValueFqns service to service (KAS/authz) API, and resource-mapping-groups
  • The authoring of SQL queries directly when utilizing sqlc means it’s better to read and better to write
  • Due to directly writing SQL, we can share specific queries with concerned and poky customers
  • Due to directly writing SQL, we can write really performant queries without the limitations we have with squirrel (no support for CTEs or subqueries leads to not using them or challenging spaghetti code)
@ryanulit ryanulit changed the title Epic: Migrate Policy SQL database queries to sqlc Epic: Migrate Policy SQL database queries to sqlc Aug 22, 2024
@jrschumacher jrschumacher added the comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry) label Aug 27, 2024
@cassandrabailey293
Copy link
Contributor

this has been moved to tracking in Jira: https://virtru.atlassian.net/browse/DSP-68

closing this duplicate, please track status of this epic in Jira.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:policy Policy Configuration ( attributes, subject mappings, resource mappings, kas registry)
Projects
None yet
Development

No branches or pull requests

3 participants