Skip to content

Commit

Permalink
Add using future simple_scoping; by default to 6.0 projects (#1427)
Browse files Browse the repository at this point in the history
Support for edgedb/edgedb#7766
  • Loading branch information
msullivan authored Dec 13, 2024
1 parent 978f853 commit b8e76cf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/portable/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(())
}

Expand Down
3 changes: 3 additions & 0 deletions src/portable/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Channel> {
// Only one argument in CLI is allowed
// So we skip channel if version is set, since version unambiguously
Expand Down

0 comments on commit b8e76cf

Please sign in to comment.