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

fix SchemaCompiler filterPrimaryKey #1915

Merged
merged 3 commits into from
Feb 28, 2024

Conversation

MonaMayrhofer
Copy link
Contributor

I think this fixes the issue I described in #1914.

I would love to add unit tests for this, however I wasn't able to find the right place to put them - If unit tests are wanted here I'd love a little guidance.

@amitaibu
Copy link
Collaborator

I would love to add unit tests for this

Maybe here? https://github.com/digitallyinduced/ihp/blob/master/Test/IDE/SchemaDesigner/CompilerSpec.hs

@MonaMayrhofer
Copy link
Contributor Author

Im not sure a file in test/IDE is the right place tho... the code in question isn't part of the IDE per se, and all the other tests in the file are testing the compiler for Schema.sql and as far as i can tell have nothing to do with the Query Builder, right?

@amitaibu
Copy link
Collaborator

You are right. Let's get Marc's feedback on that 😄

@mpscholten
Copy link
Member

Thanks for the issue and the PR :) (and sorry for the delay in the review)

We could put it into Test.SchemaCompilerSpec?

@MonaMayrhofer
Copy link
Contributor Author

That sounds reasonable!👍🏻

getInstanceDecl errored if the instance that is searched for is at the end of file and doesn't have any newlines trailing it
@@ -460,4 +460,4 @@ getInstanceDecl instanceName full =
takeInstanceDecl (line:rest)
| isEmpty line = []
| otherwise = line : takeInstanceDecl rest
takeInstanceDecl [] = error "never encountered newline?"
takeInstanceDecl [] = [] -- EOF reached
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to draw attention to this change here

In the test cases the instance I am looking for is the last one in the generated code, which resulted in an error, even tho i think it's totally fine. That this results in an error looked like a simple oversight to me so I changed it - the tests still pass... However a second opinion would be great in cause this actually had a deeper reason.

Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me 👍

@MonaMayrhofer
Copy link
Contributor Author

I think this is ready for review 😊

Copy link
Member

@mpscholten mpscholten left a comment

Choose a reason for hiding this comment

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

Thanks 👍 looks great, will merge once tests have run through

@@ -460,4 +460,4 @@ getInstanceDecl instanceName full =
takeInstanceDecl (line:rest)
| isEmpty line = []
| otherwise = line : takeInstanceDecl rest
takeInstanceDecl [] = error "never encountered newline?"
takeInstanceDecl [] = [] -- EOF reached
Copy link
Member

Choose a reason for hiding this comment

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

Looks good to me 👍

@mpscholten mpscholten merged commit 6971e39 into digitallyinduced:master Feb 28, 2024
2 checks passed
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