Is there an existing issue for this?
Current Behavior
I have a struct that looks like this:
type ComputerInventory struct {
ID string `json:"id,omitempty"`
Udid string `json:"udid,omitempty"`
... (omitted)
General *ComputerInventoryDataSubsetGeneral `json:"general,omitempty"`
ExtensionAttributes *[]ComputerInventoryDataSubsetExtensionAttributes `json:"extensionAttributes,omitempty"`
}
type ComputerInventoryDataSubsetGeneral struct {
Name string `json:"name,omitempty"`
...
ExtensionAttributes []struct {
DefinitionID string `json:"definitionId,omitempty"`
Name string `json:"name,omitempty"`
... (omitted)
} `json:"extensionAttributes,omitempty"`
}
Note that ComputerInventory and ComputerInventoryDataSubsetGeneral contain a ExtensionAttribute field.
I have this table:
func ComputerInventoryTable() *schema.Table {
return &schema.Table{
Name: "jamf_computer_inventory",
Description: "Jamf Computers",
Transform: transformers.TransformWithStruct(
&jamf.ComputerInventory{},
transformers.WithPrimaryKeys("ID"),
transformers.WithUnwrapStructFields("General"),
// transformers.WithSkipFields(),
),
Resolver: fetchComputers,
}
}
So during column creation, General is unwrapped, leading to an extension_attributes and a general_extension_attributes field in the database.
Goal: I want to skip the root ComputerInventory ExtensionAttributes field, but not skip the General one.
What I do: Add ExtensionAttributes to the WithSkipFields
What actually happens: Both ExtensionAttributes fields are removed -- the root and the child one.
Expected Behavior
ExtensionAttributes on the root struct is removed while the General.ExtensionAttributes field remains.
CloudQuery (redacted) config
unneccessary
Steps To Reproduce
- Have a struct like the following:
type Example struct {
ExtensionAttributes string
Child struct {
ExtensionAttributes string
}
}
- Construct a table with this struct. Unwrap the
Child field. Skip the ExtensionAttributes field.
func AbcTable() *schema.Table {
return &schema.Table{
Name: "abc",
Description: "abc",
Transform: transformers.TransformWithStruct(
&Example{},
transformers.WithUnwrapStructFields("Child"),
transformers.WithSkipFields("ExtensionAttributes"),
),
Resolver: fetchAbc,
}
}
Expectation: Root ExtensionAttributes field is skipped while the Child field remains.
CloudQuery (redacted) logs
CloudQuery version
6.5.0
Additional Context
In the plugin-sdk when it starts unwrapping fields, it uses t.ignoreField(sf) to determine whether it should skip a field.
https://github.com/cloudquery/plugin-sdk/blob/b185e11bad937fbbeb9178f88f0ede749088efc7/transformers/struct.go#L58-L74
But sf.Name is simply just ExtensionAttributes for both the root field and the internal General struct being unwrapped. So there is no way to distinguish between the two. sf.Name perhaps should be prefixed with the name of the parent field. That way, you can do WithSkipFields("ExtensionAttributes") vs. WithSkipFields("General.ExtensionAttributes") or something.
Pull request (optional)
Is there an existing issue for this?
Current Behavior
I have a struct that looks like this:
Note that
ComputerInventoryandComputerInventoryDataSubsetGeneralcontain aExtensionAttributefield.I have this table:
So during column creation,
Generalis unwrapped, leading to anextension_attributesand ageneral_extension_attributesfield in the database.Goal: I want to skip the root
ComputerInventoryExtensionAttributesfield, but not skip theGeneralone.What I do: Add
ExtensionAttributesto theWithSkipFieldsWhat actually happens: Both
ExtensionAttributesfields are removed -- the root and the child one.Expected Behavior
ExtensionAttributeson the root struct is removed while theGeneral.ExtensionAttributesfield remains.CloudQuery (redacted) config
unneccessary
Steps To Reproduce
Childfield. Skip theExtensionAttributesfield.Expectation: Root
ExtensionAttributesfield is skipped while theChildfield remains.CloudQuery (redacted) logs
CloudQuery version
6.5.0
Additional Context
In the plugin-sdk when it starts unwrapping fields, it uses
t.ignoreField(sf)to determine whether it should skip a field.https://github.com/cloudquery/plugin-sdk/blob/b185e11bad937fbbeb9178f88f0ede749088efc7/transformers/struct.go#L58-L74
But
sf.Nameis simply justExtensionAttributesfor both the root field and the internalGeneralstruct being unwrapped. So there is no way to distinguish between the two.sf.Nameperhaps should be prefixed with the name of the parent field. That way, you can doWithSkipFields("ExtensionAttributes")vs.WithSkipFields("General.ExtensionAttributes")or something.Pull request (optional)