From 213d0db16be96c16a63666be21f48bf7ee8d761b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Strzali=C5=84ski?= Date: Fri, 22 Nov 2024 14:24:22 +0100 Subject: [PATCH] Remove unnecessary AST serializations (#1029) --- quesma/quesma/schema_transformer.go | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/quesma/quesma/schema_transformer.go b/quesma/quesma/schema_transformer.go index 3d906bb82..9f6e3ad36 100644 --- a/quesma/quesma/schema_transformer.go +++ b/quesma/quesma/schema_transformer.go @@ -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