diff --git a/CHANGELOG.md b/CHANGELOG.md index e615195..ae5de38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +## [0.17.0] - 2023-09-19 + +* Support environment variables substituion for SQL and system commands. + For compatibility, this feature is by default disabled, and can be enabled by adding `control substitution on` to the test file. + ``` + control substitution on + + query TTTT + SELECT + '$foo' -- short + , '${foo}' -- long + , '${bar:default}' -- default value + , '${bar:$foo-default}' -- recursive default value + FROM baz; + ---- + ... + ``` + + Besides, there's a special variable `$__TEST_DIR__` which is the path to a temporary directory specific to the current test case. + This can be helpful if you need to manipulate some external resources during the test. + ``` + control substitution on + + statement ok + COPY (SELECT * FROM foo) TO '$__TEST_DIR__/foo.txt'; + + system ok + echo "foo" > "$__TEST_DIR__/foo.txt" + ``` + + Changes: + - (parser) **Breaking change**: Add `Control::Substitution`. Mark `Control` as `#[non_exhaustive]`. + - (runner) **Breaking change**: Remove `enable_testdir`. For migration, one should now enable general substitution by the `control` statement and use a dollar-prefixed `$__TEST_DIR__`. + ## [0.16.0] - 2023-09-15 * Support running external system commands with the syntax below. This is useful for manipulating some external resources during the test. diff --git a/Cargo.lock b/Cargo.lock index b5715a0..16b8758 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1451,7 +1451,7 @@ dependencies = [ [[package]] name = "sqllogictest" -version = "0.16.0" +version = "0.17.0" dependencies = [ "async-trait", "educe", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "sqllogictest-bin" -version = "0.16.0" +version = "0.17.0" dependencies = [ "anyhow", "async-trait", @@ -1495,7 +1495,7 @@ dependencies = [ [[package]] name = "sqllogictest-engines" -version = "0.16.0" +version = "0.17.0" dependencies = [ "async-trait", "bytes", diff --git a/Cargo.toml b/Cargo.toml index d829456..74882c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ resolver = "2" members = ["sqllogictest", "sqllogictest-bin", "sqllogictest-engines", "tests"] [workspace.package] -version = "0.16.0" +version = "0.17.0" edition = "2021" homepage = "https://github.com/risinglightdb/sqllogictest-rs" keywords = ["sql", "database", "parser", "cli"] diff --git a/sqllogictest-bin/Cargo.toml b/sqllogictest-bin/Cargo.toml index fd30801..c3f7c33 100644 --- a/sqllogictest-bin/Cargo.toml +++ b/sqllogictest-bin/Cargo.toml @@ -24,8 +24,8 @@ glob = "0.3" itertools = "0.11" quick-junit = { version = "0.3" } rand = "0.8" -sqllogictest = { path = "../sqllogictest", version = "0.16" } -sqllogictest-engines = { path = "../sqllogictest-engines", version = "0.16" } +sqllogictest = { path = "../sqllogictest", version = "0.17" } +sqllogictest-engines = { path = "../sqllogictest-engines", version = "0.17" } tokio = { version = "1", features = [ "rt", "rt-multi-thread", diff --git a/sqllogictest-engines/Cargo.toml b/sqllogictest-engines/Cargo.toml index 43acb3e..0504b2e 100644 --- a/sqllogictest-engines/Cargo.toml +++ b/sqllogictest-engines/Cargo.toml @@ -19,7 +19,7 @@ postgres-types = { version = "0.2.5", features = ["derive", "with-chrono-0_4"] } rust_decimal = { version = "1.30.0", features = ["tokio-pg"] } serde = { version = "1", features = ["derive"] } serde_json = "1" -sqllogictest = { path = "../sqllogictest", version = "0.16" } +sqllogictest = { path = "../sqllogictest", version = "0.17" } thiserror = "1" tokio = { version = "1", features = [ "rt", diff --git a/sqllogictest/src/parser.rs b/sqllogictest/src/parser.rs index 0e59ddd..f894190 100644 --- a/sqllogictest/src/parser.rs +++ b/sqllogictest/src/parser.rs @@ -319,6 +319,7 @@ impl OnOff { } #[derive(Debug, PartialEq, Eq, Clone)] +#[non_exhaustive] pub enum Control { /// Control sort mode. SortMode(SortMode),