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

Make mutation pre/post checks optional #635

Merged
merged 5 commits into from
Oct 25, 2024

Conversation

codedmart
Copy link
Contributor

@codedmart codedmart commented Oct 25, 2024

What

pub table_name: sql::ast::TableName,
pub by_columns: NonEmpty<metadata::database::ColumnInfo>,
pub columns_prefix: String,
pub pre_check: Option<CheckArgument>,
Copy link
Contributor

Choose a reason for hiding this comment

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

The Option here isn't necessary, this can be CheckArgument.

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 optional that the user provides the argument, but the argument will always be in the schema, just nullable)

@@ -24,7 +24,7 @@ pub struct InsertMutation {
pub table_name: sql::ast::TableName,
pub objects_argument_name: models::ArgumentName,
pub columns: BTreeMap<models::FieldName, metadata::database::ColumnInfo>,
pub post_check: CheckArgument,
pub post_check: Option<CheckArgument>,
Copy link
Contributor

Choose a reason for hiding this comment

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

The Option here isn't necessary, this can be CheckArgument.

@@ -32,18 +32,11 @@ pub struct UpdateByKey {
pub by_columns: NonEmpty<metadata::database::ColumnInfo>,
pub columns_prefix: String,
pub update_columns_argument_name: models::ArgumentName,
pub pre_check: Constraint,
pub post_check: Constraint,
pub pre_check: Option<CheckArgument>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Both the Options here aren't necessary, they can be CheckArgument.

let post_predicate_json =
mutation.post_check
.as_ref()
.and_then(|post_check| arguments.get(&post_check.argument_name))
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@danieljharvey danieljharvey changed the title Remove v2 prefix in point mutations and pre/post checks optional Make mutation pre/post checks optional Oct 25, 2024
@danieljharvey danieljharvey added this pull request to the merge queue Oct 25, 2024
Merged via the queue into main with commit dc8ef3e Oct 25, 2024
30 checks passed
@danieljharvey danieljharvey deleted the codedmart/postgres-updates branch October 25, 2024 14:46
github-merge-queue bot pushed a commit that referenced this pull request Oct 25, 2024
<!-- The PR description should answer 2 (maybe 3) important questions:
-->

### What

Pulled from #635 into own PR.

We add `mutations_prefix: Option<String>` to v5 configuration. When left
`null` (for existing projects), we default to `v2_mutation_name`, but it
can be replaced with `horse_mutation_name` etc.

Most people will just want to use it to remove the prefix though, and
that is the default for new projects. `mutationsPrefix: ""` will get rid
of the prefix altogether, which I assume most users would want.

### How

<!-- How is it trying to accomplish it (what are the implementation
steps)? -->

---------

Co-authored-by: Brandon Martin <brandon@codedmart.com>
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.

2 participants