diff --git a/src/portable/project.rs b/src/portable/project.rs index 609dc521..dd9916b7 100644 --- a/src/portable/project.rs +++ b/src/portable/project.rs @@ -66,6 +66,13 @@ const FUTURES_SCHEMA: &str = "\ using future nonrecursive_access_policies;\n\ "; +const SIMPLE_SCOPING_SCHEMA: &str = "\ + # Use a simpler algorithm for resolving the scope of object names.\n\ + # This behavior will become the default in Gel 7.0.\n\ + # See: https://docs.edgedb.com/database/edgeql/path_resolution#new-path-scoping\n\ + using future simple_scoping;\n\ +"; + #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] pub struct ProjectInfo { instance_name: String, @@ -1466,6 +1473,13 @@ fn write_schema_default(dir: &Path, version: &Query) -> anyhow::Result<()> { fs::write(&tmp, FUTURES_SCHEMA)?; fs::rename(&tmp, &futures)?; }; + if version.is_simple_scoping_needed() { + let futures = dir.join(format!("scoping.{BRANDING_SCHEMA_FILE_EXT}")); + let tmp = tmp_file_path(&futures); + fs::remove_file(&tmp).ok(); + fs::write(&tmp, SIMPLE_SCOPING_SCHEMA)?; + fs::rename(&tmp, &futures)?; + }; Ok(()) } diff --git a/src/portable/repository.rs b/src/portable/repository.rs index a17d5ad3..2e829e52 100644 --- a/src/portable/repository.rs +++ b/src/portable/repository.rs @@ -713,6 +713,9 @@ impl Query { }) .unwrap_or(false) } + pub fn is_simple_scoping_needed(&self) -> bool { + self.version.as_ref().map(|f| f.major == 6).unwrap_or(false) + } pub fn cli_channel(&self) -> Option { // Only one argument in CLI is allowed // So we skip channel if version is set, since version unambiguously