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

experiment(psl/query-engine-wasm): create QE-specific ValidatedSchema, adopt binary (de)serialization for query-engine-wasm #4696

Closed
wants to merge 10 commits into from
194 changes: 193 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions libs/query-engine-common/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct EngineBuilderNative {

/// Everything needed to connect to the database and have the core running.
pub struct EngineBuilder {
pub schema: Arc<psl::ValidatedSchema>,
pub schema: Arc<psl::ValidatedSchemaForQE>,
pub engine_protocol: EngineProtocol,

#[cfg(not(target_arch = "wasm32"))]
Expand All @@ -63,7 +63,7 @@ pub struct ConnectedEngineNative {

/// Internal structure for querying and reconnecting with the engine.
pub struct ConnectedEngine {
pub schema: Arc<psl::ValidatedSchema>,
pub schema: Arc<psl::ValidatedSchemaForQE>,
pub query_schema: Arc<QuerySchema>,
pub executor: crate::Executor,
pub engine_protocol: EngineProtocol,
Expand Down
2 changes: 1 addition & 1 deletion prisma-fmt/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub(crate) fn run(schema: &str) -> String {
let datamodel_result = psl::parse_configuration(schema);

match datamodel_result {
Ok(validated_configuration) => {
Ok((validated_configuration, _)) => {
if validated_configuration.datasources.len() != 1 {
"[]".to_string()
} else if let Some(datasource) = validated_configuration.datasources.first() {
Expand Down
2 changes: 1 addition & 1 deletion prisma-fmt/src/code_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub(crate) fn available_actions(schema: String, params: CodeActionParams) -> Vec

let file = SourceFile::new_allocated(Arc::from(schema.into_boxed_str()));

let validated_schema = psl::validate(file);
let (validated_schema, _) = psl::validate(file);

let config = &validated_schema.configuration;

Expand Down
4 changes: 2 additions & 2 deletions prisma-fmt/src/get_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn get_config_impl(params: GetConfigParams) -> Result<serde_json::Value, GetConf
}
};

let mut config = psl::parse_configuration(&params.prisma_schema).map_err(wrap_get_config_err)?;
let (mut config, warnings) = psl::parse_configuration(&params.prisma_schema).map_err(wrap_get_config_err)?;

if !params.ignore_env_var_errors {
let overrides: Vec<(_, _)> = params.datasource_overrides.into_iter().collect();
Expand All @@ -65,7 +65,7 @@ fn get_config_impl(params: GetConfigParams) -> Result<serde_json::Value, GetConf
.map_err(wrap_get_config_err)?;
}

Ok(psl::get_config(&config))
Ok(psl::get_config((&config, &warnings)))
}

#[cfg(test)]
Expand Down
3 changes: 1 addition & 2 deletions prisma-fmt/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ pub struct MiniError {
}

pub(crate) fn run(schema: &str) -> String {
let schema = psl::validate(schema.into());
let diagnostics = &schema.diagnostics;
let (_, diagnostics) = psl::validate(schema.into());

let mut mini_errors: Vec<MiniError> = diagnostics
.errors()
Expand Down