Skip to content

Commit

Permalink
Merge pull request #120 from honeycombio/jharley.bugfix-order-ascending
Browse files Browse the repository at this point in the history
bugfix: 'ascending' sort order always showing diff
  • Loading branch information
jharley authored Feb 17, 2022
2 parents 20b142f + 774d572 commit bc5ef34
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 8 additions & 1 deletion honeycombio/data_source_query_specification.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,14 @@ func extractOrders(d *schema.ResourceData) []honeycombio.OrderSpec {

so, ok := d.GetOk(fmt.Sprintf("order.%d.order", i))
if ok {
order.Order = honeycombio.SortOrderPtr(honeycombio.SortOrder(so.(string)))
ov := honeycombio.SortOrder(so.(string))
// ascending is the default, API doesn't return or require
// the field unless value is descending
//
// not sending to avoid constant plan diffs
if ov != honeycombio.SortOrderAsc {
order.Order = honeycombio.SortOrderPtr(ov)
}
}

// TODO: validation
Expand Down
5 changes: 2 additions & 3 deletions honeycombio/data_source_query_specification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ data "honeycombio_query_specification" "test" {
}
order {
column = "column_1"
order = "descending"
order = "ascending"
}
having {
Expand Down Expand Up @@ -124,8 +124,7 @@ const expectedJSON string = `{
"column": "duration_ms"
},
{
"column": "column_1",
"order": "descending"
"column": "column_1"
}
],
"havings": [
Expand Down

0 comments on commit bc5ef34

Please sign in to comment.