Skip to content

Commit

Permalink
Remove unnecessary AST serializations (#1029)
Browse files Browse the repository at this point in the history
  • Loading branch information
nablaone authored Nov 22, 2024
1 parent 82fff6f commit 213d0db
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions quesma/quesma/schema_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -759,24 +759,32 @@ func (s *SchemaCheckPass) Transform(queries []*model.Query) ([]*model.Query, err
for k, query := range queries {
var err error

if !s.cfg.Logging.EnableSQLTracing {
query.TransformationHistory.SchemaTransformers = append(query.TransformationHistory.SchemaTransformers, "n/a")
}

for _, transformation := range transformationChain {

inputQuery := query.SelectCommand.String()
var inputQuery string

if s.cfg.Logging.EnableSQLTracing {
inputQuery = query.SelectCommand.String()
}

query, err = transformation.Transformation(query.Schema, query)
if err != nil {
return nil, err
}
if query.SelectCommand.String() != inputQuery {

query.TransformationHistory.SchemaTransformers = append(query.TransformationHistory.SchemaTransformers, transformation.TransformationName)

if s.cfg.Logging.EnableSQLTracing {
if s.cfg.Logging.EnableSQLTracing {
if query.SelectCommand.String() != inputQuery {
query.TransformationHistory.SchemaTransformers = append(query.TransformationHistory.SchemaTransformers, transformation.TransformationName)
logger.Info().Msgf(transformation.TransformationName+" triggered, input query: %s", inputQuery)
logger.Info().Msgf(transformation.TransformationName+" triggered, output query: %s", query.SelectCommand.String())
}
}

}

queries[k] = query
}
return queries, nil
Expand Down

0 comments on commit 213d0db

Please sign in to comment.