File: regex5.js

package info (click to toggle)
mongodb 1%3A1.4.4-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,816 kB
  • ctags: 11,368
  • sloc: cpp: 58,805; ansic: 18,160; python: 1,255; sh: 238; makefile: 82
file content (47 lines) | stat: -rw-r--r-- 1,945 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

t = db.regex5
t.drop()

t.save( { x : [ "abc" , "xyz1" ] } )
t.save( { x : [ "ac" , "xyz2" ] } )

a = /.*b.*c/
x = /.*y.*/

doit = function() {
    
    assert.eq( 1 , t.find( { x : a } ).count() , "A" );
    assert.eq( 2 , t.find( { x : x } ).count() , "B" );
    assert.eq( 2 , t.find( { x : { $in: [ x ] } } ).count() , "C" ); // SERVER-322
    assert.eq( 1 , t.find( { x : { $in: [ a, "xyz1" ] } } ).count() , "D" ); // SERVER-322
    assert.eq( 2 , t.find( { x : { $in: [ a, "xyz2" ] } } ).count() , "E" ); // SERVER-322
    assert.eq( 1 , t.find( { x : { $all : [ a , x ] } } ).count() , "F" ); // SERVER-505
    assert.eq( 1 , t.find( { x : { $all : [ a , "abc" ] } } ).count() , "G" ); // SERVER-505
    assert.eq( 0 , t.find( { x : { $all : [ a , "ac" ] } } ).count() , "H" ); // SERVER-505
    assert.eq( 0 , t.find( { x : { $nin: [ x ] } } ).count() , "I" ); // SERVER-322
    assert.eq( 1 , t.find( { x : { $nin: [ a, "xyz1" ] } } ).count() , "J" ); // SERVER-322
    assert.eq( 0 , t.find( { x : { $nin: [ a, "xyz2" ] } } ).count() , "K" ); // SERVER-322
    assert.eq( 2 , t.find( { x : { $not: { $nin: [ x ] } } } ).count() , "L" ); // SERVER-322
    assert.eq( 1 , t.find( { x : { $nin: [ /^a.c/ ] } } ).count() , "M" ) // SERVER-322
}

doit();
t.ensureIndex( {x:1} );
print( "now indexed" );
doit();

// check bound unions SERVER-322
assert.eq( [
            [ {x:1},{x:1} ],
            [ {x:2.5},{x:2.5} ],
            [ {x:"a"},{x:"a"} ],
            [ {x:"b"},{x:"e"} ],
            [ {x:/^b/},{x:/^b/} ],
            [ {x:/^c/},{x:/^c/} ],            
            [ {x:/^d/},{x:/^d/} ]
            ],
            t.find( { x : { $in: [ 1, 2.5, "a", "b", /^b/, /^c/, /^d/ ] } } ).explain().indexBounds );

// SERVER-505
assert.eq( [ [ {x:"a"}, {x:"a"} ] ], t.find( { x : { $all: [ "a", /^a/ ] } } ).explain().indexBounds );
assert.eq( [ [ {x:"a"}, {x:"b"} ] ], t.find( { x : { $all: [ /^a/ ] } } ).explain().indexBounds );