Skip to content

Commit

Permalink
Remove sorter cfg feature, support all ORDER BY by default (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
panarch authored Jan 7, 2022
1 parent 858e545 commit d7f8c81
Show file tree
Hide file tree
Showing 15 changed files with 4 additions and 68 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jobs:
run: cargo clippy --no-default-features --features alter-table -- -D warnings
- name: Clippy (index)
run: cargo clippy --no-default-features --features index -- -D warnings
- name: Clippy (sorter)
run: cargo clippy --no-default-features --features sorter -- -D warnings
- name: Clippy (alter-table & index)
run: cargo clippy --no-default-features --features "alter-table index" -- -D warnings
- name: Clippy (alter-table & transaction)
Expand Down
9 changes: 2 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ all-features = true
[dependencies]
gluesql-core = { path = "./core" }
test-suite = { path = "./test-suite", optional = true }
memory-storage = { path = "./storages/memory-storage", optional = true, features = ["sorter"] }
sled-storage = { path = "./storages/sled-storage", optional = true, features = ["sorter"] }
memory-storage = { path = "./storages/memory-storage", optional = true }
sled-storage = { path = "./storages/sled-storage", optional = true }

[features]
# DB User
default = [
"gluesql-core/sorter",
"gluesql-core/alter-table",
"gluesql-core/index",
"gluesql-core/transaction",
Expand All @@ -53,10 +52,6 @@ transaction = ["gluesql-core/transaction", "test-suite/transaction"]
# e.g. SHOW TABLES;
metadata = ["gluesql-core/metadata", "test-suite/metadata"]

# optional: ORDER BY for non-indexed expressions
# disable this feature if you use GlueSQL for big data analysis.
sorter = ["gluesql-core/sorter", "test-suite/sorter"]

[dev-dependencies]
futures = "0.3"

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@ fn main() {
[dependencies.gluesql]
version = "0.9"
default-features = false
features = ["sorter", "alter-table", "index", "transaction"]
features = ["alter-table", "index", "transaction"]
```

#### Four features below are also optional
#### Three features below are also optional

- `sorter` - ORDER BY support for non-indexed expressions.
- `alter-table` - ALTER TABLE query support
- `index` - CREATE INDEX & DROP INDEX, index support
- `transaction` - BEGIN, ROLLBACK and COMMIT, transaction support
Expand Down
3 changes: 0 additions & 3 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,3 @@ clap = { version = "3.0.1", features = ["derive"] }
rustyline = "9.1"
rustyline-derive = "0.6"
comfy-table = "5"

[features]
default = ["gluesql-core/sorter", "sled-storage/sorter", "memory-storage/sorter"]
4 changes: 0 additions & 4 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,3 @@ transaction = []
# optional: METADATA
# e.g. SHOW TABLES;
metadata = []

# optional: ORDER BY for non-indexed expressions
# disable this feature if you use GlueSQL for big data analysis.
sorter = []
4 changes: 0 additions & 4 deletions core/src/executor/select/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ pub enum SelectError {
#[error("table alias for blend not found: {0}")]
BlendTableAliasNotFound(String),

#[cfg(not(feature = "sorter"))]
#[error("order by on non-indexed expression is not supported: {0:?}")]
OrderByOnNonIndexedExprNotSupported(Vec<crate::ast::OrderByExpr>),

#[error("unreachable!")]
Unreachable,
}
5 changes: 0 additions & 5 deletions core/src/executor/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ pub async fn select_with_labels<'a, T: Debug>(
}
};

#[cfg(not(feature = "sorter"))]
if !order_by.is_empty() {
return Err(SelectError::OrderByOnNonIndexedExprNotSupported(order_by.to_vec()).into());
}

let TableWithJoins { relation, joins } = &table_with_joins;
let table = Table::new(relation)?;

Expand Down
4 changes: 0 additions & 4 deletions storages/memory-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ async-trait = "0.1"

[dev-dependencies]
test-suite = { path = "../../test-suite", features = [
"sorter",
"alter-table",
"index",
"transaction",
Expand All @@ -24,6 +23,3 @@ test-suite = { path = "../../test-suite", features = [

tokio = { version = "1", features = ["rt", "macros"] }
futures = "0.3"

[features]
sorter = ["gluesql-core/sorter"]
4 changes: 0 additions & 4 deletions storages/sled-storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ sled = "0.34"

[dev-dependencies]
test-suite = { path = "../../test-suite", features = [
"sorter",
"index",
"transaction",
"alter-table",
Expand All @@ -34,6 +33,3 @@ tokio = { version = "1", features = ["rt", "macros"] }
[[bench]]
name = "sled_benchmark"
harness = false

[features]
sorter = ["gluesql-core/sorter"]
1 change: 0 additions & 1 deletion test-suite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ uuid = "0.8"
chrono = "0.4"

[features]
sorter = ["gluesql-core/sorter"]
alter-table = ["gluesql-core/alter-table"]
index = ["gluesql-core/index"]
transaction = ["gluesql-core/transaction"]
Expand Down
1 change: 0 additions & 1 deletion test-suite/src/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ pub use expr::expr;
pub use nested::nested;
pub use null::null;
pub use order_by::order_by;
#[cfg(feature = "sorter")]
pub use order_by::order_by_multi;
pub use value::value;
1 change: 0 additions & 1 deletion test-suite/src/index/order_by.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ CREATE TABLE Test (
);
});

#[cfg(feature = "sorter")]
test_case!(order_by_multi, async move {
run!(
r#"
Expand Down
1 change: 0 additions & 1 deletion test-suite/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ macro_rules! generate_index_tests {
glue!(index_expr, index::expr);
glue!(index_value, index::value);
glue!(index_order_by, index::order_by);
#[cfg(feature = "sorter")]
glue!(index_order_by_multi, index::order_by_multi);
};
}
Expand Down
1 change: 0 additions & 1 deletion test-suite/src/limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ test_case!(limit, async move {
r#"SELECT * FROM Test LIMIT 4 OFFSET 3;"#,
select!(id; I64; 4; 5; 6; 7),
),
#[cfg(feature = "sorter")]
(
"SELECT * FROM Test ORDER BY id DESC LIMIT 3",
select!(id; I64; 8; 7; 6),
Expand Down
27 changes: 0 additions & 27 deletions test-suite/src/order_by.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use {crate::*, gluesql_core::translate::TranslateError};

#[cfg(feature = "sorter")]
test_case!(order_by, async move {
run!(
r#"
Expand Down Expand Up @@ -151,29 +150,3 @@ CREATE TABLE Test (
"SELECT * FROM Test ORDER BY id NULLS FIRST"
);
});

#[cfg(not(feature = "sorter"))]
test_case!(order_by, async move {
use {
gluesql_core::ast::{Expr, OrderByExpr},
gluesql_core::executor::SelectError,
};

run!("CREATE TABLE Test (id INTEGER);");

test!(
Err(
SelectError::OrderByOnNonIndexedExprNotSupported(vec![OrderByExpr {
expr: Expr::Identifier("id".to_owned()),
asc: Some(false),
}])
.into()
),
"SELECT * FROM Test ORDER BY id DESC"
);

test!(
Err(TranslateError::OrderByNullsFirstOrLastNotSupported.into()),
"SELECT * FROM Test ORDER BY id NULLS LAST"
);
});

0 comments on commit d7f8c81

Please sign in to comment.