Skip to content

Commit

Permalink
Taking schema into account to resolve internal field name (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelewski authored Jul 11, 2024
1 parent acfc980 commit e0a55a9
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions quesma/quesma/schema_transformer.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,11 @@ func (v *GeoIpVisitor) VisitSelectCommand(e model.SelectCommand) interface{} {
if col, ok := expr.(model.ColumnRef); ok {
// This checks if the column is of type point
// and if it is, it appends the lat and lon columns to the group by clause
if schemaInstance.Fields[schema.FieldName(col.ColumnName)].Type.Name == schema.TypePoint.Name {
field := schemaInstance.Fields[schema.FieldName(col.ColumnName)]
if field.Type.Name == schema.TypePoint.Name {
// TODO suffixes ::lat, ::lon are hardcoded for now
groupBy = append(groupBy, model.NewColumnRef(col.ColumnName+"::lat"))
groupBy = append(groupBy, model.NewColumnRef(col.ColumnName+"::lon"))
groupBy = append(groupBy, model.NewColumnRef(field.InternalPropertyName.AsString()+"::lat"))
groupBy = append(groupBy, model.NewColumnRef(field.InternalPropertyName.AsString()+"::lon"))
} else {
groupBy = append(groupBy, groupByExpr)
}
Expand All @@ -265,10 +266,11 @@ func (v *GeoIpVisitor) VisitSelectCommand(e model.SelectCommand) interface{} {
if col, ok := expr.(model.ColumnRef); ok {
// This checks if the column is of type point
// and if it is, it appends the lat and lon columns to the select clause
if schemaInstance.Fields[schema.FieldName(col.ColumnName)].Type.Name == schema.TypePoint.Name {
field := schemaInstance.Fields[schema.FieldName(col.ColumnName)]
if field.Type.Name == schema.TypePoint.Name {
// TODO suffixes ::lat, ::lon are hardcoded for now
columns = append(columns, model.NewColumnRef(col.ColumnName+"::lat"))
columns = append(columns, model.NewColumnRef(col.ColumnName+"::lon"))
columns = append(columns, model.NewColumnRef(field.InternalPropertyName.AsString()+"::lat"))
columns = append(columns, model.NewColumnRef(field.InternalPropertyName.AsString()+"::lon"))
} else {
columns = append(columns, expr.Accept(v).(model.Expr))
}
Expand Down

0 comments on commit e0a55a9

Please sign in to comment.