Skip to content

Commit

Permalink
Implement transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski committed Jan 16, 2025
1 parent c167f3f commit ecc5de9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion quesma/processors/base_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (p *BaseProcessor) GetSupportedBackendConnectors() []quesma_api.BackendConn
}

func (p *BaseProcessor) executeQuery(query string) ([]quesma_api.QueryResultRow, error) {
logger.Debug().Msg("BaseProcessor: executeQuery")
logger.Debug().Msgf("BaseProcessor: executeQuery:%s", query)
// This will be forwarded to the query execution engine
return nil, nil
}
Expand Down
1 change: 1 addition & 0 deletions quesma/quesma/v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func full_workflow_scenario() quesma_api.QuesmaBuilder {
var queryProcessor quesma_api.Processor = NewQueryComplexProcessor()

queryTransformationPipe := NewQueryTransformationPipeline()
queryTransformationPipe.AddTransformer(NewQueryTransformer1())
queryProcessor.RegisterTransfomationPipeline(queryTransformationPipe)
queryPipeline.AddProcessor(queryProcessor)
quesmaBuilder.AddPipeline(queryPipeline)
Expand Down
16 changes: 16 additions & 0 deletions quesma/quesma/v2_test_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,19 @@ func (p *QueryTransformationPipeline) ComposeResult(results [][]quesma_api.Query
resp = append(resp, []byte("qqq->")...)
return resp
}

type QueryTransformer1 struct {
}

func (p *QueryTransformer1) Transform(queries []*quesma_api.Query) ([]*quesma_api.Query, error) {
logger.Debug().Msg("SimpleQueryTransformationPipeline: Transform")
// Do basic transformation
for _, query := range queries {
query.Query += " WHERE id = 1"
}
return queries, nil
}

func NewQueryTransformer1() *QueryTransformer1 {
return &QueryTransformer1{}
}

0 comments on commit ecc5de9

Please sign in to comment.