Skip to content

Bug 1990850: Handle property and dependency values of type BLOB in ListBundles. #159

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

Merged
merged 1 commit into from
Aug 7, 2021
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
4 changes: 2 additions & 2 deletions staging/operator-registry/pkg/sqlite/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -991,12 +991,12 @@ tip (depth) AS (
GROUP BY all_entry.operatorbundle_name, all_entry.package_name, all_entry.channel_name
),
merged_properties (bundle_name, merged) AS (
SELECT operatorbundle_name, json_group_array(json_object('type', properties.type, 'value', properties.value))
SELECT operatorbundle_name, json_group_array(json_object('type', CAST(properties.type AS TEXT), 'value', CAST(properties.value AS TEXT)))
FROM properties
GROUP BY operatorbundle_name
),
merged_dependencies (bundle_name, merged) AS (
SELECT operatorbundle_name, json_group_array(json_object('type', dependencies.type, 'value', CAST(dependencies.value AS TEXT)))
SELECT operatorbundle_name, json_group_array(json_object('type', CAST(dependencies.type AS TEXT), 'value', CAST(dependencies.value AS TEXT)))
FROM dependencies
GROUP BY operatorbundle_name
)
Expand Down
31 changes: 31 additions & 0 deletions staging/operator-registry/pkg/sqlite/query_sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,37 @@ func TestListBundlesQuery(t *testing.T) {
require.False(rows.Next())
},
},
{
Name: "properties and depdendencies columns may be stored as sqlite type blob",
OmitManfests: true,
Setup: func(t *testing.T, db *sql.DB) {
for _, stmt := range []string{
`insert into package (name, default_channel) values ("package", "channel")`,
`insert into channel (name, package_name, head_operatorbundle_name) values ("channel", "package", "bundle")`,
`insert into operatorbundle (name, bundle) values ("bundle-a", "{}")`,
`insert into channel_entry (package_name, channel_name, operatorbundle_name, entry_id, depth) values ("package", "channel", "bundle-a", 1, 0)`,
`insert into properties (type, value, operatorbundle_name) values (CAST("blob_ptype" AS BLOB), CAST("blob_pvalue" AS BLOB), "bundle-a")`,
`insert into dependencies (type, value, operatorbundle_name) values (CAST("blob_dtype" AS BLOB), CAST("blob_dvalue" AS BLOB), "bundle-a")`,
} {
if _, err := db.Exec(stmt); err != nil {
t.Fatalf("unexpected error executing setup statements: %v", err)
}
}

},
Expect: func(t *testing.T, rows *sql.Rows) {
require := require.New(t)
require.True(rows.Next())
var (
props, deps sql.NullString
c interface{}
)
require.NoError(rows.Scan(&c, &c, &c, &c, &c, &c, &c, &c, &c, &c, &deps, &props))
require.Equal(sql.NullString{Valid: true, String: `[{"type":"blob_ptype","value":"blob_pvalue"}]`}, props)
require.Equal(sql.NullString{Valid: true, String: `[{"type":"blob_dtype","value":"blob_dvalue"}]`}, deps)
require.False(rows.Next())
},
},
{
Name: "manifests not omitted with bundlepath",
OmitManfests: true,
Expand Down

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