Skip to content

Commit 31df7c0

Browse files
committed
test: regression test for order by in clause subquery
1 parent 1de04b4 commit 31df7c0

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

packages/cipherstash-proxy-integration/src/select/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ mod group_by;
22
mod order_by;
33
mod order_by_with_null;
44
mod pg_catalog;
5+
mod regression;
56
mod unmappable;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#[cfg(test)]
2+
mod tests {
3+
use crate::common::{insert, query_by, random_id, trace};
4+
5+
///
6+
/// IN clause subquery should be able to use ORDER BY
7+
///
8+
#[tokio::test]
9+
async fn select_with_order_by_in_subquery() {
10+
trace();
11+
12+
let id = random_id();
13+
let encrypted_text = "hello".to_string();
14+
15+
let sql = "INSERT INTO encrypted (id, encrypted_text) VALUES ($1, $2)";
16+
insert(sql, &[&id, &encrypted_text]).await;
17+
18+
let sql = "SELECT encrypted_text FROM encrypted WHERE id IN (SELECT id FROM encrypted WHERE id = $1 ORDER BY id DESC LIMIT 10 OFFSET 0) GROUP BY encrypted_text";
19+
20+
let result = query_by::<String>(sql, &id).await;
21+
22+
let expected = vec![encrypted_text];
23+
assert_eq!(expected, result);
24+
}
25+
}

0 commit comments

Comments
 (0)