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

Add support for ODATA $filter, $select and $count on /scanConfigs #84

Merged
merged 15 commits into from
Mar 6, 2023

Conversation

ghost
Copy link

@ghost ghost commented Feb 21, 2023

No description provided.

@ghost ghost force-pushed the odata_filter branch 2 times, most recently from f074819 to 19c8cad Compare February 22, 2023 12:42
@ghost ghost changed the title [DNM] [POC] ODATA support for ScanConfigs API Add support for ODATA $filter, $select and $count on /scanConfigs Feb 22, 2023
@ghost ghost force-pushed the odata_filter branch 2 times, most recently from 68e2b6c to cf07208 Compare March 2, 2023 17:05
if err != nil {
return nil, fmt.Errorf("failed to convert scanID %v to uuid: %v", id, err)
return ret, fmt.Errorf("failed to convert scanID %v to uuid: %v", scan.Id, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

need to print *scan.Id, right?

return sc, nil
}

func getExistingScanConfigbyID(db *gorm.DB, scanConfig models.ScanConfig) (ScanConfig, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

By

Copy link
Contributor

Choose a reason for hiding this comment

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

we can pass only the id here


// Fields for complex field types
ComplexFieldSchemas []string
DescriminatorProperty string
Copy link
Contributor

Choose a reason for hiding this comment

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

Discriminator :)


// nolint:gocognit,cyclop
func (st *selectNode) insert(path []*godata.Token, filter *godata.GoDataFilterQuery, sel *godata.GoDataSelectQuery, subExpand *godata.GoDataExpandQuery, expand bool) error {
// If path length == 0 then we've reach the bottom of the path and now
Copy link
Contributor

Choose a reason for hiding this comment

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

we've reached the bottom of the path, and ...

}

// Parse $select using ParseExpandString because godata.ParseSelectString
// is a nieve implementation and doesn't handle query options properly
Copy link
Contributor

Choose a reason for hiding this comment

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

naive

}

// nolint:gocognit,cyclop
func (st *selectNode) insert(path []*godata.Token, filter *godata.GoDataFilterQuery, sel *godata.GoDataSelectQuery, subExpand *godata.GoDataExpandQuery, expand bool) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

worth putting a todo here to ad a unit test. I think that it will also make it more clear with input and output examples

* Covers most usecases with a fake DB and dataset
* Fixes a couple of bugs with expand
* Switches $filter to use / separated paths like $select/$expand
@akpsgit akpsgit merged commit e2048d0 into main Mar 6, 2023
@akpsgit akpsgit deleted the odata_filter branch March 6, 2023 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants