Skip to content

Commit

Permalink
fix review
Browse files Browse the repository at this point in the history
  • Loading branch information
Weakky committed May 17, 2024
1 parent c4705eb commit 28c8f38
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use mongodb::{
use mongodb_schema_describer::MongoSchema;
use schema_connector::{warnings::Model, IntrospectionContext, IntrospectionResult, Warnings};
use statistics::*;
use std::borrow::Cow;

/// From the given database, lists all collections as models, and samples
/// maximum of SAMPLE_SIZE documents for their fields with the following rules:
Expand Down Expand Up @@ -66,7 +67,7 @@ pub(super) async fn sample(
for file_id in ctx.previous_schema().db.iter_file_ids() {
let file_name = ctx.previous_schema().db.file_name(file_id);

data_model.create_empty_file(file_name.to_string());
data_model.create_empty_file(Cow::Borrowed(file_name));
}

statistics.render(ctx, &mut data_model, &mut warnings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use once_cell::sync::Lazy;
use psl::datamodel_connector::constraint_names::ConstraintNames;
use regex::Regex;
use std::{
borrow::Cow,
cmp::Ordering,
collections::{BTreeMap, HashMap, HashSet},
fmt,
Expand Down Expand Up @@ -416,7 +417,7 @@ impl<'a> Statistics<'a> {
None => ctx.introspection_file_name(),
};

rendered.push_composite_type(file_name.to_string(), r#type);
rendered.push_composite_type(Cow::Borrowed(file_name), r#type);
}

for (model_name, model) in models.into_iter() {
Expand All @@ -425,7 +426,7 @@ impl<'a> Statistics<'a> {
None => ctx.introspection_file_name(),
};

rendered.push_model(file_name.to_string(), model);
rendered.push_model(Cow::Borrowed(file_name), model);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::introspection::datamodel_calculator::DatamodelCalculatorContext;
use datamodel_renderer as renderer;
use psl::PreviewFeature;
use schema_connector::ViewDefinition;
use std::borrow::Cow;

/// Combines the SQL database schema and an existing PSL schema to a
/// PSL schema definition string.
Expand All @@ -29,7 +30,7 @@ pub(crate) fn to_psl_string(
for file_id in ctx.previous_schema.db.iter_file_ids() {
let file_name = ctx.previous_schema.db.file_name(file_id);

datamodel.create_empty_file(file_name.to_string());
datamodel.create_empty_file(Cow::Borrowed(file_name));
}

enums::render(introspection_file_name, ctx, &mut datamodel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ use crate::introspection::{
};
use datamodel_renderer::datamodel as renderer;
use schema_connector::ViewDefinition;
use std::borrow::Cow;

/// Render all view blocks to the PSL.
pub(super) fn render<'a>(
introspection_file_name: &str,
introspection_file_name: &'a str,
ctx: &'a DatamodelCalculatorContext<'a>,
rendered: &mut renderer::Datamodel<'a>,
) -> Vec<ViewDefinition> {
Expand Down Expand Up @@ -39,7 +40,7 @@ pub(super) fn render<'a>(
None => introspection_file_name,
};

rendered.push_view(file_name.to_string(), render);
rendered.push_view(Cow::Borrowed(file_name), render);
}

definitions
Expand Down

0 comments on commit 28c8f38

Please sign in to comment.