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

Fix datasource URL override for c-abi engine #4863

Merged
merged 1 commit into from
May 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 12 additions & 14 deletions query-engine/query-engine-c-abi/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,23 @@ impl QueryEngine {

let datamodel = get_cstr_safe(constructor_options.datamodel).expect("Datamodel must be present");
let mut schema = psl::validate(datamodel.into());

let config = &mut schema.configuration;
config
.resolve_datasource_urls_query_engine(
&overrides,
|key| env.get(key).map(ToString::to_string),
// constructor_options.ignore_env_var_errors,
true,
)
.map_err(|err| ApiError::conversion(err, schema.db.source_assert_single()))?;
// extract the url for later use in apply_migrations
let url = schema
.configuration
let url = config
.datasources
.first()
.unwrap()
.load_url(|key| env::var(key).ok())
.unwrap();

let config = &mut schema.configuration;
.map_err(|err| ApiError::conversion(err, schema.db.source_assert_single()))?;

schema
.diagnostics
Expand All @@ -155,15 +162,6 @@ impl QueryEngine {
_ => tracing::trace!("No base path provided"),
}

config
.resolve_datasource_urls_query_engine(
&overrides,
|key| env.get(key).map(ToString::to_string),
// constructor_options.ignore_env_var_errors,
true,
)
.map_err(|err| ApiError::conversion(err, schema.db.source_assert_single()))?;

config
.validate_that_one_datasource_is_provided()
.map_err(|errors| ApiError::conversion(errors, schema.db.source_assert_single()))?;
Expand Down