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

Bring ndc-postgres in line with ndc-spec RC15 #296

Merged
merged 9 commits into from
Feb 16, 2024
Merged

Conversation

i-am-tom
Copy link
Contributor

@i-am-tom i-am-tom commented Feb 14, 2024

What

This PR updates ndc-postgres to adhere to the RC15 version of ndc-spec.

How

This required a bit more work than we'd originally expected: because the format of procedure results changed, we now need to generate a new object type for each procedure (namely, the result type: a product of affected_rows (int4) and returning (whatever the underlying collection's row type is).

Base automatically changed from gil/ndc-spec-rc14 to main February 14, 2024 11:34
@soupi soupi force-pushed the gjm-tjh/ndc-spec-rc15 branch from 33658c4 to c32cd87 Compare February 14, 2024 15:17
@i-am-tom i-am-tom force-pushed the gjm-tjh/ndc-spec-rc15 branch from a425203 to c32cd87 Compare February 14, 2024 15:31
@i-am-tom i-am-tom changed the title ndc-spec RC15 [WIP] Bring ndc-postgres in line with ndc-spec RC15 Feb 15, 2024
@i-am-tom i-am-tom marked this pull request as ready for review February 15, 2024 14:36
Comment on lines +440 to +450
// If int4 doesn't exist anywhere else in the schema, we need to add it here. However, a user
// can't filter or aggregate based on the affected rows of a procedure, so we don't need to add
// any aggregate functions or comparison operators. However, if int4 exists elsewhere in the
// schema and has already been added, it will also already contain these functions and
// operators.
scalar_types
.entry("int4".to_string())
.or_insert(models::ScalarType {
aggregate_functions: BTreeMap::new(),
comparison_operators: BTreeMap::new(),
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this also required when generating the configuration?

If it is, then it will need to be moved to occurring_scalar_types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about it, even if it's not, that still feels like a better place for it. I plan on making that function private and putting the scalar types into the configuration at some point soon, so this function can just read them directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not really part of the configuration. Even if the user omits int4 from the configuration we still need to expose this type for the schema or else procedures will break, so I don't see a way out of defining it here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am convinced.

Any reason not to add it in up-front rather than mutating later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only that, if no mutations are generated, it's a type without a purpose, which we seem to be avoiding everywhere else? idk, I'm not sure what the danger is in having all scalar types declared upfront and not having the ocurring_scalar_types check, but doing it this way means we're still respecting that approach. Probably a wider question

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's better to keep the cause and effect together. We generate the type because the procedure needs it, and we don't if we don't. It's better to place them together instead of in two separate places.

@i-am-tom i-am-tom enabled auto-merge February 16, 2024 10:40
Copy link
Contributor

@SamirTalwar SamirTalwar left a comment

Choose a reason for hiding this comment

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

If you want to go straight to ndc-spec v0.1.0-rc.16, here's the places you need to hit.

I suggest not accepting these comments because you'll also need to regenerate Cargo.lock.

@@ -6,7 +6,7 @@ edition = "2021"
[dependencies]
query-engine-metadata = { path = "../query-engine/metadata" }

ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "02d26c1" }
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" }
Copy link
Contributor

Choose a reason for hiding this comment

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

We can update to RC 16 directly if you like.

Suggested change
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" }
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "ee52bae" }

@@ -21,7 +21,7 @@ query-engine-metadata = { path = "../../query-engine/metadata" }
query-engine-sql = { path = "../../query-engine/sql" }
query-engine-translation = { path = "../../query-engine/translation" }

ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "02d26c1" }
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" }
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "ee52bae" }

Comment on lines +37 to +38
ndc-client = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ndc-client = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
ndc-client = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.16" }
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.16" }

@@ -5,7 +5,7 @@ edition = "2021"
license = "Apache-2.0"

[dependencies]
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "02d26c1" }
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" }
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "ee52bae" }

Comment on lines +12 to +14
ndc-client = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" }
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ndc-client = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" }
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
ndc-client = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.16" }
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "ee52bae" }
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.16" }

@@ -23,7 +23,7 @@ postgres = []
openapi-generator = { path = "../../documentation/openapi" }
ndc-postgres = { path = "../../connectors/ndc-postgres" }
ndc-postgres-configuration = { path = "../../configuration" }
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.14" }
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.15" }
ndc-test = { git = "https://github.com/hasura/ndc-spec.git", tag = "v0.1.0-rc.16" }

@i-am-tom i-am-tom added this pull request to the merge queue Feb 16, 2024
Merged via the queue into main with commit e47a46e Feb 16, 2024
28 checks passed
@i-am-tom i-am-tom deleted the gjm-tjh/ndc-spec-rc15 branch February 16, 2024 11:33
@soupi
Copy link
Contributor

soupi commented Feb 16, 2024

I think separate steps are better.

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