Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ jobs:
if: matrix.directory == 'service'
uses: sqlc-dev/setup-sqlc@bac53b7fb28c039a6c7f5736fd1e89744021bdd6 # v5.0.0
with:
sqlc-version: '1.31.0'
sqlc-version: '1.31.1'
- name: verify sqlc generate
if: matrix.directory == 'service'
run: make policy-sql-gen
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
MODS=protocol/go lib/ocrypto lib/fixtures lib/flattening lib/identifier sdk service examples otdfctl tests-bdd
HAND_MODS=lib/ocrypto lib/fixtures lib/flattening lib/identifier sdk service examples otdfctl tests-bdd
REQUIRED_BUF_VERSION=1.70.0
REQUIRED_SQLC_VERSION=1.31.0
REQUIRED_SQLC_VERSION=1.31.1

ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))

Expand Down
253 changes: 237 additions & 16 deletions service/integration/attributes_test.go

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions service/integration/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"testing"

"github.com/opentdf/platform/protocol/go/policy/namespaces"
"github.com/opentdf/platform/service/internal/fixtures"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -44,6 +45,18 @@ func forceDeleteRows(ctx context.Context, db fixtures.DBInterface, table string,
return err
}

func deleteNamespaces(ctx context.Context, tb testing.TB, db fixtures.DBInterface, ids []string) {
tb.Helper()

for _, id := range ids {
ns, err := db.PolicyClient.GetNamespace(ctx, &namespaces.GetNamespaceRequest_NamespaceId{NamespaceId: id})
require.NoError(tb, err)

_, err = db.PolicyClient.UnsafeDeleteNamespace(ctx, ns, ns.GetFqn())
require.NoError(tb, err)
}
}

// forceCreatedAtTie sets created_at to a fixed timestamp for the given IDs,
// guaranteeing that the ORDER BY tiebreaker (id ASC) determines sort order.
func forceCreatedAtTie(ctx context.Context, db fixtures.DBInterface, table string, ids []string) error {
Expand Down
2 changes: 1 addition & 1 deletion service/policy/db/actions.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/attribute_fqn.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/attribute_values.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions service/policy/db/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,13 @@ func (c PolicyDBClient) ListAttributes(ctx context.Context, r *attributes.ListAt
}

sortField, sortDirection := GetAttributesSortParams(r.GetSort())
search := pgtypeSubstringSearchPattern(r.GetSearch().GetTerm())

list, err := c.queries.listAttributesDetail(ctx, listAttributesDetailParams{
Active: active,
NamespaceID: pgtypeUUID(namespaceID),
NamespaceName: pgtypeText(namespaceName),
Search: search,
Limit: limit,
Offset: offset,
SortField: sortField,
Expand Down
32 changes: 23 additions & 9 deletions service/policy/db/attributes.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/copyfrom.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/key_access_server_registry.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/key_management.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/namespaces.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/obligations.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions service/policy/db/queries/attributes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ WHERE
(sqlc.narg('active')::BOOLEAN IS NULL OR ad.active = sqlc.narg('active')) AND
(sqlc.narg('namespace_id')::uuid IS NULL OR ad.namespace_id = sqlc.narg('namespace_id')::uuid) AND
(sqlc.narg('namespace_name')::text IS NULL OR n.name = sqlc.narg('namespace_name')::text)
-- No search-specific optimization is added here. If needed, consider
-- a pg_trgm-backed GIN index on attribute_fqns.fqn.
AND (
sqlc.narg('search')::TEXT IS NULL
OR fqns.fqn LIKE sqlc.narg('search')::TEXT ESCAPE '\'
)
Comment thread
c-r33d marked this conversation as resolved.
GROUP BY ad.id, n.name, fqns.fqn, p.resolved_field, p.resolved_direction
ORDER BY
CASE WHEN p.resolved_field = 'name' AND p.resolved_direction = 'ASC' THEN ad.name END ASC,
Expand Down
2 changes: 1 addition & 1 deletion service/policy/db/registered_resources.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/resource_mapping.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service/policy/db/subject_mappings.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading