Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: split queries.sql into files by table #762

Merged
merged 9 commits into from Apr 1, 2022
Merged

Conversation

coadler
Copy link
Member

@coadler coadler commented Mar 31, 2022

No description provided.

@coadler coadler self-assigned this Mar 31, 2022
@codecov
Copy link

codecov bot commented Mar 31, 2022

Codecov Report

Merging #762 (55476d7) into main (2b1a0ee) will increase coverage by 1.67%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #762      +/-   ##
==========================================
+ Coverage   64.25%   65.93%   +1.67%     
==========================================
  Files         199      200       +1     
  Lines       11861    13179    +1318     
  Branches       87       87              
==========================================
+ Hits         7621     8689    +1068     
- Misses       3420     3603     +183     
- Partials      820      887      +67     
Flag Coverage Δ
unittest-go- 65.35% <ø> (+2.07%) ⬆️
unittest-go-macos-latest 52.35% <ø> (-6.64%) ⬇️
unittest-go-ubuntu-latest 55.14% <ø> (-6.75%) ⬇️
unittest-go-windows-2022 51.85% <ø> (-6.31%) ⬇️
unittest-js 62.63% <ø> (ø)
Impacted Files Coverage Δ
coderd/database/queries.sql.go 83.30% <ø> (ø)
pty/start_other.go 64.70% <0.00%> (-23.53%) ⬇️
provisionersdk/serve.go 35.13% <0.00%> (-8.11%) ⬇️
coderd/provisionerdaemons.go 60.03% <0.00%> (-3.04%) ⬇️
coderd/parameter/compute.go 74.07% <0.00%> (-2.23%) ⬇️
coderd/workspaceresources.go 57.72% <0.00%> (-1.63%) ⬇️
provisionerd/provisionerd.go 80.32% <0.00%> (-0.59%) ⬇️
peer/conn.go 79.18% <0.00%> (+0.76%) ⬆️
cli/cliui/agent.go 82.45% <0.00%> (+5.26%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b1a0ee...55476d7. Read the comment docs.

Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

I'm not a fan of the Go files this generates.

It misuses _ inside of Go file names, and makes the majority of files in the database package generated, which makes others harder to read.

Is it possible to output all generated into a single file like before? I love the separated SQL files, but it seems unnecessary to have separated generated Go files.

@coadler coadler marked this pull request as ready for review March 31, 2022 21:58
@@ -30,6 +30,7 @@ CREATE TABLE projects (

-- Enforces no active projects have the same name.
CREATE UNIQUE INDEX ON projects (organization_id, name) WHERE deleted = FALSE;
CREATE UNIQUE INDEX idx_projects_name_lower ON projects USING btree (lower(name));
Copy link
Member Author

Choose a reason for hiding this comment

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

@kylecarbs we seemed to be querying these by their lowercase names so I added indexes for them as well.

Copy link
Member

Choose a reason for hiding this comment

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

Ahh wise. Good change!

@coadler coadler requested a review from kylecarbs March 31, 2022 22:00
Copy link
Member

@kylecarbs kylecarbs left a comment

Choose a reason for hiding this comment

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

Minor things! Neat change.

--output ./coderd/database/query.sql
sed -i 's/@ /@/g' ./coderd/database/query.sql
fmt/sql: $(wildcard coderd/database/queries/*.sql)
# TODO: this is slightly slow
Copy link
Member

Choose a reason for hiding this comment

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

Could we use bash wait to make this faster?

Copy link
Member Author

Choose a reason for hiding this comment

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

The biggest problem is that it has to attempt to install via npx every time, otherwise it's pretty fast! Can npx be called concurrently?

Copy link
Member

Choose a reason for hiding this comment

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

Ohhhhhh. I say we require sql-formatter installed globally then.

coderd/database/generate.sh Show resolved Hide resolved
@coadler coadler merged commit fd52310 into main Apr 1, 2022
@coadler coadler deleted the colin/query-files branch April 1, 2022 20:45
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.

None yet

2 participants