Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
trzysiek committed Dec 26, 2024
1 parent 91e5ea5 commit ab48db7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 6 additions & 3 deletions quesma/quesma/schema_search_after_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func (s searchAfterStrategyType) String() string {

type searchAfterStrategyBulletproof struct{} // TODO, don't look!

// validateAndParse validates the 'searchAfter', which is what came from the request's search_after field.
func (s searchAfterStrategyBulletproof) validateAndParse(query *model.Query, indexSchema schema.Schema) (searchAfterParameterParsed []model.Expr, err error) {
logger.Debug().Msgf("searchAfter: %v", query.SearchAfter)
if query.SearchAfter == nil {
Expand Down Expand Up @@ -103,6 +104,7 @@ func (s searchAfterStrategyBulletproof) transform(query *model.Query, searchAfte

type searchAfterStrategyJustDiscardTheParameter struct{}

// validateAndParse validates the 'searchAfter', which is what came from the request's search_after field.
func (s searchAfterStrategyJustDiscardTheParameter) validateAndParse(*model.Query, schema.Schema) (searchAfterParameterParsed []model.Expr, err error) {
return nil, nil
}
Expand All @@ -111,12 +113,13 @@ func (s searchAfterStrategyJustDiscardTheParameter) transform(query *model.Query
return query, nil
}

// -------------------------------------------------------------------
// | First, simple strategy: BasicAndFast (default for just a second |
// -------------------------------------------------------------------
// ----------------------------------------------------------------------------------
// | First, simple strategy: BasicAndFast (default until Bulletproof is implemented |
// ----------------------------------------------------------------------------------

type searchAfterStrategyBasicAndFast struct{}

// validateAndParse validates the 'searchAfter', which is what came from the request's search_after field.
func (s searchAfterStrategyBasicAndFast) validateAndParse(query *model.Query, indexSchema schema.Schema) (searchAfterParsed []model.Expr, err error) {
if query.SearchAfter == nil {
return nil, nil
Expand Down
5 changes: 2 additions & 3 deletions quesma/quesma/schema_search_after_transformer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,10 @@ func Test_applySearchAfterParameter(t *testing.T) {
for _, strategy := range strategies {
for i, tc := range testcases {
t.Run(fmt.Sprintf("%v (testNr:%d)", tc.searchAfter, i), func(t *testing.T) {
// apply search_after parameter, easier to do here than in all the testcases
tc.query.SearchAfter = tc.searchAfter
tc.transformedQueryExpected.SearchAfter = tc.searchAfter
if i > 8 {
t.Skip()
}

transformer := NewSchemaCheckPass(&config.QuesmaConfiguration{IndexConfig: indexConfig}, tableDiscovery, strategy)
actual, err := transformer.applySearchAfterParameter(Schema, tc.query)
assert.Equal(t, tc.errorExpected, err != nil, "Expected error: %v, got: %v", tc.errorExpected, err)
Expand Down

0 comments on commit ab48db7

Please sign in to comment.