Skip to content

Commit

Permalink
fix: Handle PrimaryKeyComponents in packaging (#1503)
Browse files Browse the repository at this point in the history


Handle PrimaryKeyComponents in packaging
  • Loading branch information
bbernays committed Jan 31, 2024
1 parent ce12a61 commit 8c8fdc9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions serve/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

cloudquery_api "github.com/cloudquery/cloudquery-api-go"
"github.com/cloudquery/plugin-sdk/v4/plugin"
"github.com/cloudquery/plugin-sdk/v4/schema"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -80,8 +81,11 @@ func (s *PluginServe) writeTablesJSON(ctx context.Context, dir string) error {
Type: column.Type.String(),
IncrementalKey: column.IncrementalKey,
NotNull: column.NotNull,
PrimaryKey: column.PrimaryKey,
Unique: column.Unique,
// PrimaryKey Will be set to true Under the following conditions:
// 1. If the column is a `PrimaryKeyComponent`
// 2. If the column is a `PrimaryKey` and both of the following are true column name is NOT `_cq_id` and there are other columns that are a PrimaryKeyComponent
PrimaryKey: (column.PrimaryKey && !(column.Name == schema.CqIDColumn.Name && len(table.PrimaryKeyComponents()) > 0)) || column.PrimaryKeyComponent,
Unique: column.Unique,
})
}
tablesToEncode = append(tablesToEncode, cloudquery_api.PluginTableCreate{
Expand Down

1 comment on commit 8c8fdc9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱️ Benchmark results

  • Glob-8 ns/op: 91.82

Please sign in to comment.