Skip to content

Commit

Permalink
Merge pull request #3178 from Razican/ipnetwork_update
Browse files Browse the repository at this point in the history
Updated ipnetwork to 0.19
  • Loading branch information
weiznich authored Jun 15, 2022
2 parents b5c2e26 + eaf68d8 commit df7ca0a
Show file tree
Hide file tree
Showing 47 changed files with 880 additions and 332 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.54.0
toolchain: 1.56.0
profile: minimal
override: true
- name: Cache cargo registry
Expand Down Expand Up @@ -347,7 +347,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.54.0
toolchain: 1.56.0
profile: minimal
components: clippy, rustfmt
override: true
Expand Down Expand Up @@ -462,13 +462,13 @@ jobs:
run: cargo -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "sqlite extras libsqlite3-sys libsqlite3-sys/bundled libsqlite3-sys/with-asan" --target x86_64-unknown-linux-gnu

minimal_rust_version:
name: Check Minimal supported rust version (1.54.0)
name: Check Minimal supported rust version (1.56.0)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.54.0
toolchain: 1.56.0
profile: minimal
override: true
- name: Cache cargo registry
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Increasing the minimal supported Rust version will always be coupled at least wi

### Changed

* The minimal officially supported rustc version is now 1.54.0
* The minimal officially supported rustc version is now 1.56.0

* Interacting with a database requires a mutable connection.

Expand Down
6 changes: 3 additions & 3 deletions diesel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository = "https://github.com/diesel-rs/diesel"
keywords = ["orm", "database", "sql"]
categories = ["database"]
edition = "2018"
rust-version = "1.54.0"
rust-version = "1.56.0"

[dependencies]
byteorder = { version = "1.0", optional = true }
Expand All @@ -24,7 +24,7 @@ serde_json = { version = ">=0.8.0, <2.0", optional = true }
url = { version = "2.1.0", optional = true }
percent-encoding = { version = "2.1.0", optional = true }
uuid = { version = ">=0.7.0, <2.0.0", optional = true }
ipnetwork = { version = ">=0.12.2, <0.19.0", optional = true }
ipnetwork = { version = ">=0.12.2, <0.20.0", optional = true }
ipnet = { version = "2.5.0", optional = true }
num-bigint = { version = ">=0.2.0, <0.5.0", optional = true }
num-traits = { version = "0.2.0", optional = true }
Expand All @@ -41,7 +41,7 @@ path = "../diesel_derives"
[dev-dependencies]
cfg-if = "1"
dotenvy = "0.15"
ipnetwork = ">=0.12.2, <0.19.0"
ipnetwork = ">=0.12.2, <0.20.0"
quickcheck = "1.0.3"

[features]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,46 @@ macro_rules! tuple_impls {
}

macro_rules! impl_contains_defaultable_value {
(
@build
start_ts = [$($ST: ident,)*],
ts = [$T1: ident,],
bounds = [$($bounds: tt)*],
out = [$($out: tt)*],
)=> {
impl<$($ST,)*> ContainsDefaultableValue for ($($ST,)*)
where
$($ST: ContainsDefaultableValue,)*
$($bounds)*
$T1::Out: Any<$($out)*>,
{
type Out = <$T1::Out as Any<$($out)*>>::Out;
}

};
(
@build
start_ts = [$($ST: ident,)*],
ts = [$T1: ident, $($T: ident,)+],
bounds = [$($bounds: tt)*],
out = [$($out: tt)*],
)=> {
impl_contains_defaultable_value! {
@build
start_ts = [$($ST,)*],
ts = [$($T,)*],
bounds = [$($bounds)* $T1::Out: Any<$($out)*>,],
out = [<$T1::Out as Any<$($out)*>>::Out],
}
};
($T1: ident, $($T: ident,)+) => {
impl<$T1, $($T,)*> ContainsDefaultableValue for ($T1, $($T,)*)
where $T1: ContainsDefaultableValue,
($($T,)*): ContainsDefaultableValue,
$T1::Out: Any<<($($T,)*) as ContainsDefaultableValue>::Out>
{
type Out = <$T1::Out as Any<<($($T,)*) as ContainsDefaultableValue>::Out>>::Out;
}
impl_contains_defaultable_value! {
@build
start_ts = [$T1, $($T,)*],
ts = [$($T,)*],
bounds = [],
out = [$T1::Out],
}
};
($T1: ident,) => {
impl<$T1> ContainsDefaultableValue for ($T1,)
Expand Down
6 changes: 3 additions & 3 deletions diesel_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ keywords = ["diesel", "migrations", "cli"]
autotests = false
edition = "2018"
include = ["src/**/*", "LICENSE-*", "README.md"]
rust-version = "1.54.0"
rust-version = "1.56.0"

[[bin]]
name = "diesel"
Expand All @@ -20,8 +20,8 @@ doc = false

[dependencies]
chrono = { version = "0.4.19", default-features = false, features = ["clock", "std"] }
clap = "3.1"
clap_complete = "3.1"
clap = "3.2.1"
clap_complete = "3.2"
dotenvy = "0.15"
heck = "0.4.0"
serde = { version = "1.0.0", features = ["derive"] }
Expand Down
24 changes: 15 additions & 9 deletions diesel_cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use crate::validators::num::*;
use clap::{Arg, Command};
use clap::{
builder::{EnumValueParser, PossibleValuesParser},
Arg, Command,
};
use clap_complete::Shell;

fn str_as_char(str: &str) -> char {
Expand Down Expand Up @@ -45,7 +47,7 @@ pub fn build_cli() -> Command<'static> {
)
.default_value("1")
.takes_value(true)
.validator(is_positive_int)
.value_parser(clap::value_parser!(u64))
.conflicts_with("REVERT_ALL"),
),
)
Expand Down Expand Up @@ -79,7 +81,7 @@ pub fn build_cli() -> Command<'static> {
)
.default_value("1")
.takes_value(true)
.validator(is_positive_int)
.value_parser(clap::value_parser!(u64))
.conflicts_with("REDO_ALL"),
),
)
Expand Down Expand Up @@ -114,7 +116,8 @@ pub fn build_cli() -> Command<'static> {
.arg(
Arg::new("MIGRATION_FORMAT")
.long("format")
.possible_values(&["sql", "barrel"])
.value_parser(PossibleValuesParser::new(["sql"]))
.takes_value(true)
.default_value("sql")
.takes_value(true)
.help("The format of the migration to be generated."),
Expand Down Expand Up @@ -154,7 +157,7 @@ pub fn build_cli() -> Command<'static> {
Arg::new("SHELL")
.index(1)
.required(true)
.possible_values(Shell::possible_values()),
.value_parser(EnumValueParser::<Shell>::new()),
);

let infer_schema_subcommand = Command::new("print-schema")
Expand All @@ -171,7 +174,7 @@ pub fn build_cli() -> Command<'static> {
.index(1)
.takes_value(true)
.multiple_values(true)
.multiple_occurrences(true)
.action(clap::ArgAction::Append)
.help("Table names to filter (default only-tables if not empty)."),
)
.arg(
Expand All @@ -198,20 +201,21 @@ pub fn build_cli() -> Command<'static> {
.long("column-sorting")
.help("Sort order for table columns.")
.takes_value(true)
.possible_values(&["ordinal_position", "name"]),
.value_parser(PossibleValuesParser::new(["ordinal_position", "name"])),
)
.arg(
Arg::new("patch-file")
.long("patch-file")
.takes_value(true)
.value_parser(clap::value_parser!(std::path::PathBuf))
.help("A unified diff file to be applied to the final schema."),
)
.arg(
Arg::new("import-types")
.long("import-types")
.takes_value(true)
.multiple_values(true)
.multiple_occurrences(true)
.action(clap::ArgAction::Append)
.number_of_values(1)
.help("A list of types to import for every table, separated by commas."),
)
Expand All @@ -222,6 +226,7 @@ pub fn build_cli() -> Command<'static> {
);

let config_arg = Arg::new("CONFIG_FILE")
.value_parser(clap::value_parser!(std::path::PathBuf))
.long("config-file")
.help(
"The location of the configuration file to use. Falls back to the \
Expand Down Expand Up @@ -269,5 +274,6 @@ fn migration_dir_arg<'a>() -> Arg<'a> {
current directory and its parents.",
)
.takes_value(true)
.value_parser(clap::value_parser!(std::path::PathBuf))
.global(true)
}
4 changes: 2 additions & 2 deletions diesel_cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub struct Config {
impl Config {
pub fn file_path(matches: &ArgMatches) -> PathBuf {
matches
.value_of("CONFIG_FILE")
.map(PathBuf::from)
.get_one::<PathBuf>("CONFIG_FILE")
.cloned()
.or_else(|| env::var_os("DIESEL_CONFIG_FILE").map(PathBuf::from))
.unwrap_or_else(|| find_project_root().unwrap_or_default().join("diesel.toml"))
}
Expand Down
4 changes: 2 additions & 2 deletions diesel_cli/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ pub fn schema_table_exists(database_url: &str) -> DatabaseResult<bool> {

pub fn database_url(matches: &ArgMatches) -> String {
matches
.value_of("DATABASE_URL")
.map(|s| s.into())
.get_one::<String>("DATABASE_URL")
.cloned()
.or_else(|| env::var("DATABASE_URL").ok())
.unwrap_or_else(|| handle_error(DatabaseError::DatabaseUrlMissing))
}
Expand Down
Loading

0 comments on commit df7ca0a

Please sign in to comment.