SORT CASES: Don't delete filtered-out cases. 20110513030505/pspp
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 13 May 2011 05:55:29 +0000 (22:55 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 13 May 2011 05:55:29 +0000 (22:55 -0700)
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
tests/language/stats/sort-cases.at

index f44656fda54b9e14fcf78cb50f0d9cb4495d03c8..cb60901fe64ed3dc8ca03a6df004dedc8608d079 100644 (file)
@@ -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;
 
index 0e2a1d6fd53d8263c2ee217ebd35602ce5923502..b000cb56ef36d24b5f2f0fd059a1757be04ad1ef 100644 (file)
@@ -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