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

expose procedures as part of the schema endpoint #198

Merged
merged 4 commits into from
Dec 4, 2023

Conversation

soupi
Copy link
Contributor

@soupi soupi commented Dec 4, 2023

What

We want to expose the native query procedures we defined in #189 on the /schema/ endpoint as procedures and not collections.

How

  • We add a boolean isProcedure field to native queries in the deployment.json configuration file which specifies whether they are procedures or not (default false that is skipped serialization so we maintain backwards compat).
  • We include native queries marked is is_procedure in the procedures list and not the collections list.

@@ -145,6 +145,7 @@ pub async fn get_schema(
.native_queries
.0
.iter()
.filter(|(_, info)| !info.is_procedure)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't include procedures in the collections list

Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps use Iterator::partition to filter the native queries once.

.native_queries
.0
.iter()
.filter(|(_, info)| info.is_procedure)
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 include procedures in the procedures list.

@soupi soupi marked this pull request as ready for review December 4, 2023 11:48
@plcplc plcplc self-requested a review December 4, 2023 12:06
Copy link
Contributor

@plcplc plcplc left a comment

Choose a reason for hiding this comment

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

Nice!

Comment on lines +32 to +33
#[serde(skip_serializing_if = "std::ops::Not::not")]
#[serde(default)]
Copy link
Contributor

@plcplc plcplc Dec 4, 2023

Choose a reason for hiding this comment

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

Versioning considerations:

  • Backwards compatible config (Old configurations work on new server versions. Esp, is_procedure is not a mandatory field) ✅
  • Forwards compatible config (New configurations work on older server versions) (OK if they don't use any procedures. Procedures present in the config will be fail to deserialize, IIUC) ✔️

I don't think this is an issue just now. I'm mostly writing this comment to practise being dilligent wrt versioning.

pub arguments: BTreeMap<String, ColumnInfo>,
#[serde(default)]
pub description: Option<String>,
/// Is this native query a procedure
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
/// Is this native query a procedure
/// True if this native query mutates the database

Copy link
Contributor Author

Choose a reason for hiding this comment

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

applied in df97239

@soupi soupi enabled auto-merge December 4, 2023 13:39
@soupi soupi added this pull request to the merge queue Dec 4, 2023
Merged via the queue into main with commit 51dfade Dec 4, 2023
26 checks passed
@soupi soupi deleted the gil/expose-procedures-in-schema branch December 4, 2023 13:46
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