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

Correctly transform control file version number in sql entity graph #409

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions cargo-pgx/src/command/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,10 +326,9 @@ pub(crate) fn get_version() -> eyre::Result<String> {
match get_property("default_version")? {
Some(v) => {
if v == "@CARGO_VERSION@" {
let metadata = MetadataCommand::new()
.exec()
.wrap_err("failed to parse Cargo.toml")?;
Ok(metadata.root_package().unwrap().version.to_string())
let metadata = MetadataCommand::new().exec()?;
let root_package = metadata.root_package().ok_or(eyre!("no root package found"))?;
Ok(root_package.version.to_string())
} else {
Ok(v)
}
Expand Down
9 changes: 6 additions & 3 deletions pgx/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,14 +338,17 @@ macro_rules! pg_sql_graph_magic {
> {
use pgx::datum::sql_entity_graph::reexports::eyre::WrapErr;
use std::convert::TryFrom;
let package_version = env!("CARGO_PKG_VERSION");
let context = include_str!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/",
env!("CARGO_CRATE_NAME"),
".control"
));
let control_file = pgx::datum::sql_entity_graph::ControlFile::try_from(context)
.wrap_err_with(|| "Could not parse control file, is it valid?")?;
))
.replace("@CARGO_VERSION@", package_version);
let control_file =
pgx::datum::sql_entity_graph::ControlFile::try_from(context.as_str())
.wrap_err_with(|| "Could not parse control file, is it valid?")?;
Ok(control_file)
}
};
Expand Down