-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
33658c4
to
c32cd87
Compare
a425203
to
c32cd87
Compare
crates/query-engine/translation/src/translation/mutation/translate.rs
Outdated
Show resolved
Hide resolved
crates/query-engine/translation/src/translation/mutation/translate.rs
Outdated
Show resolved
Hide resolved
crates/query-engine/translation/src/translation/mutation/translate.rs
Outdated
Show resolved
Hide resolved
// 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(), | ||
}); |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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" } |
There was a problem hiding this comment.
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.
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" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" } | |
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "ee52bae" } |
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" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "e0e9629" } | |
ndc-sdk = { git = "https://github.com/hasura/ndc-hub.git", rev = "ee52bae" } |
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" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 think separate steps are better. |
What
This PR updates
ndc-postgres
to adhere to the RC15 version ofndc-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) andreturning
(whatever the underlying collection's row type is).