Skip to content

fix(package): Normalize tables when writing tables.json#1227

Merged
kodiakhq[bot] merged 2 commits intocloudquery:mainfrom
erezrokah:fix/tables_package
Sep 20, 2023
Merged

fix(package): Normalize tables when writing tables.json#1227
kodiakhq[bot] merged 2 commits intocloudquery:mainfrom
erezrokah:fix/tables_package

Conversation

@erezrokah
Copy link
Copy Markdown
Member

Summary

We might want to refactor this to no (ab)use the MemDB plugin but I think this is ok for now. Also we should call FlattenTables otherwise we only output the top level ones


Use the following steps to ensure your PR is ready to be reviewed

  • Read the contribution guidelines 🧑‍🎓
  • Run go fmt to format your code 🖊
  • Lint your changes via golangci-lint run 🚨 (install golangci-lint here)
  • Update or add tests 🧪
  • Ensure the status checks below are successful ✅

buffer := &bytes.Buffer{}
m := json.NewEncoder(buffer)
m.SetIndent("", " ")
m.SetIndent("", "")
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want this JSON as compact as possible

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 20, 2023

⏱️ Benchmark results

Comparing with 966a1ff

  • Glob-8 ns/op: 101.7 ⬆️ 1.28% increase vs. 966a1ff

@codecov
Copy link
Copy Markdown

codecov bot commented Sep 20, 2023

Codecov Report

Patch coverage: 88.46% and project coverage change: +0.14% 🎉

Comparison is base (966a1ff) 48.63% compared to head (a86c93d) 48.77%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1227      +/-   ##
==========================================
+ Coverage   48.63%   48.77%   +0.14%     
==========================================
  Files          88       88              
  Lines        8262     8285      +23     
==========================================
+ Hits         4018     4041      +23     
  Misses       3869     3869              
  Partials      375      375              
Files Changed Coverage Δ
serve/package.go 57.93% <86.95%> (+2.52%) ⬆️
internal/memdb/memdb.go 75.97% <100.00%> (+2.28%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


if len(tables) != 0 {
if len(tables) != 2 {
t.Fatalf("Expected 0 tables but got %d", len(tables))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Fatalf("Expected 0 tables but got %d", len(tables))
t.Fatalf("Expected 2 tables but got %d", len(tables))

tablesString := string(content)

if diff := cmp.Diff(tablesString, "[{\"name\":\"table1\",\"relations\":[\"table2\"]},{\"name\":\"table2\"}]\n"); diff != "" {
t.Fatalf("unexpected files in docs directory (-want +got):\n%s", diff)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Fatalf("unexpected files in docs directory (-want +got):\n%s", diff)
t.Fatalf("unexpected content in tables.json (-want +got):\n%s", diff)

@kodiakhq kodiakhq bot merged commit 06c84c0 into cloudquery:main Sep 20, 2023
Name string `json:"name,omitempty"`
Parent *string `json:"parent,omitempty"`
Relations *[]string `json:"relations,omitempty"`
Title string `json:"title,omitempty"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we also need the columns?

@erezrokah erezrokah mentioned this pull request Sep 20, 2023
5 tasks
kodiakhq bot pushed a commit that referenced this pull request Sep 20, 2023
🤖 I have created a release *beep* *boop*
---


## [4.9.2](v4.9.1...v4.9.2) (2023-09-20)


### Bug Fixes

* **package:** Normalize tables when writing tables.json ([#1227](#1227)) ([06c84c0](06c84c0))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
kodiakhq bot pushed a commit that referenced this pull request Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants