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

refactor: make Junction non-recursive #1818

Merged
merged 3 commits into from
Apr 16, 2021

Conversation

steve-chavez
Copy link
Member

While working on #1794, I noticed that we can have recursive Junctions:

data Link
= Constraint
{ constName :: ConstraintName }
| Junction
{ junTable :: Table
, junLink1 :: Link
, junCols1 :: [Column]
, junLink2 :: Link
, junCols2 :: [Column]
}
deriving (Eq, Generic, JSON.ToJSON)

Which didn't seem right, as discussed in 5223082#r49568150.

This PR fixes that, also Cardinality now contains the constraint or junction that defines it:

data Cardinality
  = O2M ConstraintName -- ^ one-to-many cardinality
  | M2O ConstraintName -- ^ many-to-one cardinality
  | M2M Junction       -- ^ many-to-many cardinality
  deriving (Eq, Generic, JSON.ToJSON)

That makes sense IMO, it clears up the code in some parts.

Also Cardinality now includes a Junction or ConstraintName
Copy link
Member

@wolfgangwalther wolfgangwalther left a comment

Choose a reason for hiding this comment

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

The new typing is much better than a revert would have been. And also better than all my suggestions before. This also avoids to have a Junction with O2M or something like that. Nice!

I'm not seeing any codecov reports here, yet. Probably because CircleCI was running with your fork when you first uploaded without a PR, @steve-chavez. But didn't you add the codecov token or something like that in your own fork's CircleCI settings to avoid that? I remember we discussed that, at least. Anyway, I will trigger a re-run of the pipeline and then we will see whether how code coverage is with those new types.

src/PostgREST/DbStructure/Relation.hs Outdated Show resolved Hide resolved
src/PostgREST/DbStructure/Relation.hs Outdated Show resolved Hide resolved
src/PostgREST/DbStructure/Relation.hs Show resolved Hide resolved
src/PostgREST/Request/DbRequestBuilder.hs Show resolved Hide resolved
@wolfgangwalther
Copy link
Member

Anyway, I will trigger a re-run of the pipeline and then we will see whether how code coverage is with those new types.

Only... that I can't seem to do that. Can't find a way to trigger a build for a PR, that doesn't have one, yet. And I can't rerun the pipeline because it's in your workspace, not postgrest.

@wolfgangwalther
Copy link
Member

I'm not seeing any codecov reports here, yet. Probably because CircleCI was running with your fork when you first uploaded without a PR, @steve-chavez. But didn't you add the codecov token or something like that in your own fork's CircleCI settings to avoid that? I remember we discussed that, at least. Anyway, I will trigger a re-run of the pipeline and then we will see whether how code coverage is with those new types.

What might have happenend is that Codecov has reverted the token you have set up in your own CircleCI, as a consequence of the security incident.

Copy link
Member

@wolfgangwalther wolfgangwalther left a comment

Choose a reason for hiding this comment

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

Just had a look at the uncovered lines.

src/PostgREST/DbStructure/Relation.hs Show resolved Hide resolved
src/PostgREST/DbStructure/Relation.hs Show resolved Hide resolved
src/PostgREST/Request/DbRequestBuilder.hs Show resolved Hide resolved
src/PostgREST/Request/DbRequestBuilder.hs Show resolved Hide resolved
@steve-chavez steve-chavez merged commit 698bfe6 into PostgREST:main Apr 16, 2021
@steve-chavez
Copy link
Member Author

cachix push failed: https://app.circleci.com/pipelines/github/PostgREST/postgrest/917/workflows/e3706800-a3aa-4fac-8a55-2573faf1d726/jobs/8771.

Hm, circle is missing the cachix auth token right?

@wolfgangwalther
Copy link
Member

It says:

Binary cache doesn't exist or it's a private cache and you don't have access. Please check the name for typos or provide an auth token.

I remember @monacoremo suggesting to switch from signing key to token or something? In CircleCI there still seems to be signing key, not a token? Do we only need to change the environment variable - or do we need to change the CI script, too?

@steve-chavez
Copy link
Member Author

steve-chavez commented Apr 16, 2021

Do we only need to change the environment variable - or do we need to change the CI script, too?

Ah, yes, I think so. What puzzled me is that the previous commit was green: https://github.com/PostgREST/postgrest/tree/1f206a560bedf0d7971e9db5e475c37ec311acda.

in CircleCI there still seems to be signing key, not a token?

True, I'll check that out.

@wolfgangwalther
Copy link
Member

Ah, yes, I think so. What puzzled me is that the previous commit was green: https://github.com/PostgREST/postgrest/tree/1f206a560bedf0d7971e9db5e475c37ec311acda.

Yeah, that didn't touch any code, so didn't have to upload to cachix.

@monacoremo
Copy link
Member

We'll need to add a line before we push:

cachix authtoken "$CACHIX_AUTH_TOKEN"

@steve-chavez can you set the env variable up with a separate CI auth token? Happy to fix the CI then

@steve-chavez
Copy link
Member Author

steve-chavez commented Apr 17, 2021

@monacoremo Done! I set up the CACHIX_AUTH_TOKEN under the cachix context.

Note: the cachix context is already setup at

context:
- cachix

@monacoremo
Copy link
Member

@steve-chavez perfect, thank you! Just added #1821

monacoremo pushed a commit to monacoremo/postgrest that referenced this pull request Jul 17, 2021
Also Cardinality now includes a Junction or ConstraintName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants