Skip to content

Commit

Permalink
fix(query): Properly handle format outcome (#893)
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Wagner <[email protected]>
  • Loading branch information
nwagner84 authored Dec 16, 2024
1 parent 86260d5 commit 7b5ead6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
16 changes: 16 additions & 0 deletions crates/pica-cli/tests/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,22 @@ fn select_query_format() -> TestResult {
))
.stderr(predicates::str::is_empty());

let mut cmd = Command::cargo_bin("pica")?;
let assert = cmd
.arg("select")
.arg("[email protected],028R{a <$> (', ' d <*> ' (' v ')') | v in ['Vater', 'Mutter']}")
.arg(data_dir().join("ada.dat"))
.assert();

assert
.success()
.code(0)
.stdout(predicates::ord::eq(
"119232022,\"Byron, George Gordon Byron (Vater)\"\n\
119232022,\"Byron, Anne Isabella Milbanke Byron (Mutter)\"\n"
))
.stderr(predicates::str::is_empty());

Ok(())
}

Expand Down
9 changes: 6 additions & 3 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ impl Fragment {
match self {
Literal(lit) => Outcome(vec![vec![lit.clone()]]),
#[cfg(feature = "unstable")]
Format(fmt) => Outcome(vec![record
.format(fmt, &options.into())
.collect()]),
Format(fmt) => Outcome(
record
.format(fmt, &options.into())
.map(|e| vec![e])
.collect::<Vec<Vec<_>>>(),
),
Path(path) => {
let fields = record
.fields()
Expand Down

0 comments on commit 7b5ead6

Please sign in to comment.