Skip to content

Commit

Permalink
What is going wrong then
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljharvey committed Oct 25, 2024
1 parent b7cb5f0 commit 9900c8f
Show file tree
Hide file tree
Showing 7 changed files with 3,370 additions and 3,360 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub struct CheckArgument {
// but now we are able to override this
pub fn get_version_prefix(mutations_prefix: &Option<String>) -> String {
match mutations_prefix {
None => "v2_".to_string(),
None => format!("{}_", super::VERSION),
Some(str) => match str.as_str() {
"" => String::new(),
_ => format!("{str}_"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::translation::helpers::{self, TableSourceAndReference};
use crate::translation::query::filtering;
use crate::translation::query::values;
use ndc_models as models;
use ndc_postgres_configuration::Configuration;
use nonempty::NonEmpty;
use query_engine_metadata::metadata;
use query_engine_metadata::metadata::database;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ pub fn generate(
}

// Insert mutations.
let (name, insert_mutation) = insert::generate(collection_name, table_info);
let (name, insert_mutation) =
insert::generate(collection_name, table_info, mutations_prefix);
mutations.insert(name, Mutation::InsertMutation(insert_mutation));

// Update mutations.
let update_mutations = generate_update_by_unique(collection_name, table_info);
let update_mutations =
generate_update_by_unique(collection_name, table_info, mutations_prefix);
for (name, update_mutation) in update_mutations {
mutations.insert(name, Mutation::UpdateMutation(update_mutation));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use query_engine_metadata::metadata::database;
use query_engine_sql::sql;
use std::collections::{BTreeMap, BTreeSet};

use super::common::CheckArgument;
use super::common::{self, CheckArgument};

/// A representation of an auto-generated insert mutation.
///
Expand All @@ -31,8 +31,13 @@ pub struct InsertMutation {
pub fn generate(
collection_name: &models::CollectionName,
table_info: &database::TableInfo,
mutations_prefix: &Option<String>,
) -> (models::ProcedureName, InsertMutation) {
let name = format!("insert_{collection_name}").into();
let name = format!(
"{}insert_{collection_name}",
common::get_version_prefix(mutations_prefix)
)
.into();

let description = format!("Insert into the {collection_name} table");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::collections::BTreeMap;
use crate::translation::error::Error;
use crate::translation::helpers::{Env, State};
use ndc_models as models;
use ndc_postgres_configuration::Configuration;
use query_engine_sql::sql;

/// Translate a built-in delete mutation into an ExecutionPlan (SQL) to be run against the database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub struct Constraint {
pub fn generate_update_by_unique(
collection_name: &models::CollectionName,
table_info: &database::TableInfo,
mutations_prefix: &Option<String>,
) -> Vec<(models::ProcedureName, UpdateMutation)> {
table_info
.uniqueness_constraints
Expand All @@ -63,7 +64,11 @@ pub fn generate_update_by_unique(
keys,
)?;

let name = format!("update_{collection_name}_by_{constraint_name}").into();
let name = format!(
"{}update_{collection_name}_by_{constraint_name}",
common::get_version_prefix(mutations_prefix)
)
.into();

let description = format!(
"Update any row on the '{collection_name}' collection using the {}",
Expand Down
Loading

0 comments on commit 9900c8f

Please sign in to comment.