From 70add34f5bf3e08e20839f4126126bbf37164ddb Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 12 May 2011 22:55:29 -0700 Subject: [PATCH] SORT CASES: Don't delete filtered-out cases. This was first noticed by users in the GUI, but it is a problem with the implementation of SORT CASES, not a problem with the GUI. Bug #33089. Thanks to Mindaugus for reporting the problem. --- src/language/stats/sort-cases.c | 2 +- tests/language/stats/sort-cases.at | 48 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/language/stats/sort-cases.c b/src/language/stats/sort-cases.c index f44656fd..cb60901f 100644 --- a/src/language/stats/sort-cases.c +++ b/src/language/stats/sort-cases.c @@ -69,7 +69,7 @@ cmd_sort_cases (struct lexer *lexer, struct dataset *ds) } proc_discard_output (ds); - output = sort_execute (proc_open (ds), &ordering); + output = sort_execute (proc_open_filtering (ds, false), &ordering); ok = proc_commit (ds); ok = dataset_set_source (ds, output) && ok; diff --git a/tests/language/stats/sort-cases.at b/tests/language/stats/sort-cases.at index 0e2a1d6f..b000cb56 100644 --- a/tests/language/stats/sort-cases.at +++ b/tests/language/stats/sort-cases.at @@ -80,3 +80,51 @@ SORT_CASES_TEST(10000, 5, 500) SORT_CASES_TEST(50000, 1) +dnl Bug #33089 caused SORT CASES to delete filtered cases permanently. +AT_SETUP([SORT CASES preserves filtered cases]) +AT_DATA([sort-cases.sps], [dnl +DATA LIST FREE /x. +BEGIN DATA. +5 4 3 2 1 0 +END DATA. +COMPUTE mod2 = MOD(x, 2). +LIST. +FILTER BY mod2. +LIST. +SORT CASES BY x. +LIST. +FILTER OFF. +LIST. +]) +AT_CHECK([pspp -O format=csv sort-cases.sps], [0], [dnl +Table: Data List +x,mod2 +5.00,1.00 +4.00,.00 +3.00,1.00 +2.00,.00 +1.00,1.00 +.00,.00 + +Table: Data List +x,mod2 +5.00,1.00 +3.00,1.00 +1.00,1.00 + +Table: Data List +x,mod2 +1.00,1.00 +3.00,1.00 +5.00,1.00 + +Table: Data List +x,mod2 +.00,.00 +1.00,1.00 +2.00,.00 +3.00,1.00 +4.00,.00 +5.00,1.00 +]) +AT_CLEANUP -- 2.30.2