1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt2942.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,62 @@
1.4 +# 2008 February 15
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +#
1.15 +# Ticket #2942.
1.16 +#
1.17 +# Queries of the form:
1.18 +#
1.19 +# SELECT group_concat(x) FROM (SELECT * FROM table ORDER BY 1);
1.20 +#
1.21 +# The ORDER BY would be dropped by the query flattener. This used
1.22 +# to not matter because aggregate functions sum(), min(), max(), avg(),
1.23 +# and so forth give the same result regardless of the order of inputs.
1.24 +# But with the addition of the group_concat() function, suddenly the
1.25 +# order does matter.
1.26 +#
1.27 +# $Id: tkt2942.test,v 1.1 2008/02/15 14:33:04 drh Exp $
1.28 +#
1.29 +
1.30 +set testdir [file dirname $argv0]
1.31 +source $testdir/tester.tcl
1.32 +
1.33 +ifcapable !subquery {
1.34 + finish_test
1.35 + return
1.36 +}
1.37 +
1.38 +do_test tkt2942.1 {
1.39 + execsql {
1.40 + create table t1(num int);
1.41 + insert into t1 values (2);
1.42 + insert into t1 values (1);
1.43 + insert into t1 values (3);
1.44 + insert into t1 values (4);
1.45 + SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY num DESC);
1.46 + }
1.47 +} {4,3,2,1}
1.48 +do_test tkt2942.2 {
1.49 + execsql {
1.50 + SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY num);
1.51 + }
1.52 +} {1,2,3,4}
1.53 +do_test tkt2942.3 {
1.54 + execsql {
1.55 + SELECT group_concat(num) FROM (SELECT num FROM t1);
1.56 + }
1.57 +} {2,1,3,4}
1.58 +do_test tkt2942.4 {
1.59 + execsql {
1.60 + SELECT group_concat(num) FROM (SELECT num FROM t1 ORDER BY rowid DESC);
1.61 + }
1.62 +} {4,3,1,2}
1.63 +
1.64 +
1.65 +finish_test