summaryrefslogtreecommitdiff
path: root/jstests/distinct_index2.js
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2011-03-17 00:05:43 +0100
committerAntonin Kral <a.kral@bobek.cz>2011-03-17 00:05:43 +0100
commit582fc32574a3b158c81e49cb00e6ae59205e66ba (patch)
treeac64a3243e0d2121709f685695247052858115c8 /jstests/distinct_index2.js
parent2761bffa96595ac1698d86bbc2e95ebb0d4d6e93 (diff)
downloadmongodb-582fc32574a3b158c81e49cb00e6ae59205e66ba.tar.gz
Imported Upstream version 1.8.0
Diffstat (limited to 'jstests/distinct_index2.js')
-rw-r--r--jstests/distinct_index2.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/jstests/distinct_index2.js b/jstests/distinct_index2.js
new file mode 100644
index 0000000..2ba65f9
--- /dev/null
+++ b/jstests/distinct_index2.js
@@ -0,0 +1,35 @@
+t = db.distinct_index2;
+t.drop();
+
+t.ensureIndex( { a : 1 , b : 1 } )
+t.ensureIndex( { c : 1 } )
+
+function x(){
+ return Math.floor( Math.random() * 10 );
+}
+
+for ( i=0; i<2000; i++ ){
+ t.insert( { a : x() , b : x() , c : x() } )
+}
+
+correct = []
+for ( i=0; i<10; i++ )
+ correct.push( i )
+
+function check( field ){
+ res = t.distinct( field )
+ res = res.sort()
+ assert.eq( correct , res , "check: " + field );
+
+ if ( field != "a" ){
+ res = t.distinct( field , { a : 1 } )
+ res = res.sort()
+ assert.eq( correct , res , "check 2: " + field );
+ }
+}
+
+check( "a" )
+check( "b" )
+check( "c" )
+
+