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

improve type extraction #399

Merged
merged 1 commit into from
Oct 8, 2022
Merged

improve type extraction #399

merged 1 commit into from
Oct 8, 2022

Conversation

janpaepke
Copy link
Collaborator

@janpaepke janpaepke commented Jun 10, 2022

  • refactor getColumnInfo to separate responsibilities
  • make functions idempotent
  • decrease repetition
  • improve field analysis

@codecov-commenter
Copy link

Codecov Report

Merging #399 (4343aad) into master (b192f97) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #399      +/-   ##
==========================================
+ Coverage   96.78%   96.79%   +0.01%     
==========================================
  Files          32       33       +1     
  Lines        1152     1156       +4     
  Branches      218      218              
==========================================
+ Hits         1115     1119       +4     
  Misses         33       33              
  Partials        4        4              
Impacted Files Coverage Δ
packages/typegen/src/index.ts 99.35% <100.00%> (-0.01%) ⬇️
packages/typegen/src/query/column-info.ts 100.00% <100.00%> (ø)
packages/typegen/src/query/getViewResult.ts 100.00% <100.00%> (ø)
packages/typegen/src/query/parse.ts 85.47% <100.00%> (+0.12%) ⬆️

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 b192f97...4343aad. Read the comment docs.

@janpaepke
Copy link
Collaborator Author

I decided to do this in steps, as the changes are likely going to be significant.

This is already good to review, I'll create the next pr towards this branch for individual review.

@janpaepke janpaepke requested a review from mmkal June 10, 2022 16:40
Copy link
Owner

@mmkal mmkal left a comment

Choose a reason for hiding this comment

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

Looks good! Guessing the todo items in the description are not intended for this PR?

const tagOptions = (query: DescribedQuery) => {
const buildGetFieldInfo = (viewResult: ViewResult[], ast: SelectFromStatement) => {
const viewableAst =
viewResult[0]?.formatted_query === undefined ? ast : getHopefullyViewableAST(viewResult[0].formatted_query!) // TODO: explore why this fallback might be needed - can't we always use the original ast?
Copy link
Owner

Choose a reason for hiding this comment

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

Similar to last time, I’d prefer a truthiness check than an explicit comparison to undefined

@janpaepke
Copy link
Collaborator Author

Correct. They're notes for the subsequent ones :)

This is gonna take a while :)

@mmkal
Copy link
Owner

mmkal commented Jun 30, 2022

@janpaepke let's merge this! Any reason to keep it as draft for now?

A minor thing I want to add now typegen-ignore is in is (optionally) throwing when some queries couldn't be typed. But I don't want to add that on top of current main and cause conflicts.

@janpaepke
Copy link
Collaborator Author

Hey misha,

well this is really only half way there and has also changed quite a bit in my local version.
I'm still trying to figure out the best structure, but it may take a while.

We could merge this currently still only cosmetic.

@mmkal
Copy link
Owner

mmkal commented Aug 18, 2022

@janpaepke let's merge. I'd like to make some changes too, and want to reduce the chance of conflicts. Plus, cosmetic changes are still good changes! If there are small tweaks you want to make, feel free then mark ready for review. Or, if it's going to cause issues for your local somehow, let me know and I can hold off/we can figure out how to separate out this from future changes. Otherwise will just merge it at some point in the next few days.

@janpaepke
Copy link
Collaborator Author

Nah, it's good to merge.
Sorry haven't really had time for this recently, but still intend to finish it...

@mmkal mmkal marked this pull request as ready for review October 8, 2022 14:09
@mmkal mmkal merged commit 59b34ba into main Oct 8, 2022
@mmkal mmkal deleted the feature/enhance-type-extraction branch October 8, 2022 14:10
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.

3 participants