bson_ext 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +11 -6
- data/bson_ext.gemspec +1 -0
- data/ext/cbson/version.h +1 -1
- metadata +22 -34
- data/ext/cmongo/c-driver/src/bson.c +0 -699
- data/ext/cmongo/c-driver/src/bson.h +0 -229
- data/ext/cmongo/c-driver/src/gridfs.c +0 -799
- data/ext/cmongo/c-driver/src/gridfs.h +0 -278
- data/ext/cmongo/c-driver/src/md5.c +0 -381
- data/ext/cmongo/c-driver/src/md5.h +0 -91
- data/ext/cmongo/c-driver/src/mongo.c +0 -1020
- data/ext/cmongo/c-driver/src/mongo.h +0 -260
- data/ext/cmongo/c-driver/src/mongo_except.h +0 -143
- data/ext/cmongo/c-driver/src/numbers.c +0 -127
- data/ext/cmongo/c-driver/src/platform_hacks.h +0 -93
- data/ext/cmongo/c-driver/test/all_types.c +0 -223
- data/ext/cmongo/c-driver/test/auth.c +0 -28
- data/ext/cmongo/c-driver/test/benchmark.c +0 -434
- data/ext/cmongo/c-driver/test/count_delete.c +0 -64
- data/ext/cmongo/c-driver/test/endian_swap.c +0 -31
- data/ext/cmongo/c-driver/test/errors.c +0 -71
- data/ext/cmongo/c-driver/test/examples.c +0 -75
- data/ext/cmongo/c-driver/test/gridfs.c +0 -217
- data/ext/cmongo/c-driver/test/json.c +0 -169
- data/ext/cmongo/c-driver/test/pair.c +0 -41
- data/ext/cmongo/c-driver/test/replica_set.c +0 -81
- data/ext/cmongo/c-driver/test/resize.c +0 -35
- data/ext/cmongo/c-driver/test/simple.c +0 -110
- data/ext/cmongo/c-driver/test/sizes.c +0 -22
- data/ext/cmongo/c-driver/test/test.h +0 -19
- data/ext/cmongo/c-driver/test/update.c +0 -107
@@ -1,19 +0,0 @@
|
|
1
|
-
#include <stdlib.h>
|
2
|
-
|
3
|
-
#define ASSERT(x) \
|
4
|
-
do{ \
|
5
|
-
if(!(x)){ \
|
6
|
-
printf("failed assert (%d): %s\n", __LINE__, #x); \
|
7
|
-
exit(1); \
|
8
|
-
}\
|
9
|
-
}while(0)
|
10
|
-
|
11
|
-
#ifdef _WIN32
|
12
|
-
#define INIT_SOCKETS_FOR_WINDOWS \
|
13
|
-
do{ \
|
14
|
-
WSADATA out; \
|
15
|
-
WSAStartup(MAKEWORD(2,2), &out); \
|
16
|
-
} while(0)
|
17
|
-
#else
|
18
|
-
#define INIT_SOCKETS_FOR_WINDOWS do {} while(0)
|
19
|
-
#endif
|
@@ -1,107 +0,0 @@
|
|
1
|
-
#include "test.h"
|
2
|
-
#include "mongo.h"
|
3
|
-
#include <stdio.h>
|
4
|
-
#include <string.h>
|
5
|
-
#include <stdlib.h>
|
6
|
-
|
7
|
-
int main(){
|
8
|
-
mongo_connection conn[1];
|
9
|
-
bson_buffer bb;
|
10
|
-
bson obj;
|
11
|
-
bson cond;
|
12
|
-
int i;
|
13
|
-
bson_oid_t oid;
|
14
|
-
const char* col = "c.update_test";
|
15
|
-
const char* ns = "test.c.update_test";
|
16
|
-
|
17
|
-
INIT_SOCKETS_FOR_WINDOWS;
|
18
|
-
|
19
|
-
if (mongo_connect( conn , TEST_SERVER, 27017 )){
|
20
|
-
printf("failed to connect\n");
|
21
|
-
exit(1);
|
22
|
-
}
|
23
|
-
|
24
|
-
/* if the collection doesn't exist dropping it will fail */
|
25
|
-
if (!mongo_cmd_drop_collection(conn, "test", col, NULL)
|
26
|
-
&& mongo_find_one(conn, ns, bson_empty(&obj), bson_empty(&obj), NULL)){
|
27
|
-
printf("failed to drop collection\n");
|
28
|
-
exit(1);
|
29
|
-
}
|
30
|
-
|
31
|
-
bson_oid_gen(&oid);
|
32
|
-
|
33
|
-
{ /* insert */
|
34
|
-
bson_buffer_init(&bb);
|
35
|
-
bson_append_oid(&bb, "_id", &oid);
|
36
|
-
bson_append_int(&bb, "a", 3 );
|
37
|
-
bson_from_buffer(&obj, &bb);
|
38
|
-
mongo_insert(conn, ns, &obj);
|
39
|
-
bson_destroy(&obj);
|
40
|
-
}
|
41
|
-
|
42
|
-
{ /* insert */
|
43
|
-
bson op;
|
44
|
-
|
45
|
-
bson_buffer_init(&bb);
|
46
|
-
bson_append_oid(&bb, "_id", &oid);
|
47
|
-
bson_from_buffer(&cond, &bb);
|
48
|
-
|
49
|
-
bson_buffer_init(&bb);
|
50
|
-
{
|
51
|
-
bson_buffer * sub = bson_append_start_object(&bb, "$inc");
|
52
|
-
bson_append_int(sub, "a", 2 );
|
53
|
-
bson_append_finish_object(sub);
|
54
|
-
}
|
55
|
-
{
|
56
|
-
bson_buffer * sub = bson_append_start_object(&bb, "$set");
|
57
|
-
bson_append_double(sub, "b", -1.5 );
|
58
|
-
bson_append_finish_object(sub);
|
59
|
-
}
|
60
|
-
bson_from_buffer(&op, &bb);
|
61
|
-
|
62
|
-
for (i=0; i<5; i++)
|
63
|
-
mongo_update(conn, ns, &cond, &op, 0);
|
64
|
-
|
65
|
-
/* cond is used later */
|
66
|
-
bson_destroy(&op);
|
67
|
-
}
|
68
|
-
|
69
|
-
if(!mongo_find_one(conn, ns, &cond, 0, &obj)){
|
70
|
-
printf("Failed to find object\n");
|
71
|
-
exit(1);
|
72
|
-
} else {
|
73
|
-
int fields = 0;
|
74
|
-
bson_iterator it;
|
75
|
-
bson_iterator_init(&it, obj.data);
|
76
|
-
|
77
|
-
bson_destroy(&cond);
|
78
|
-
|
79
|
-
while(bson_iterator_next(&it)){
|
80
|
-
switch(bson_iterator_key(&it)[0]){
|
81
|
-
case '_': /* id */
|
82
|
-
ASSERT(bson_iterator_type(&it) == bson_oid);
|
83
|
-
ASSERT(!memcmp(bson_iterator_oid(&it)->bytes, oid.bytes, 12));
|
84
|
-
fields++;
|
85
|
-
break;
|
86
|
-
case 'a':
|
87
|
-
ASSERT(bson_iterator_type(&it) == bson_int);
|
88
|
-
ASSERT(bson_iterator_int(&it) == 3 + 5*2);
|
89
|
-
fields++;
|
90
|
-
break;
|
91
|
-
case 'b':
|
92
|
-
ASSERT(bson_iterator_type(&it) == bson_double);
|
93
|
-
ASSERT(bson_iterator_double(&it) == -1.5);
|
94
|
-
fields++;
|
95
|
-
break;
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
ASSERT(fields == 3);
|
100
|
-
}
|
101
|
-
|
102
|
-
bson_destroy(&obj);
|
103
|
-
|
104
|
-
mongo_cmd_drop_db(conn, "test");
|
105
|
-
mongo_destroy(conn);
|
106
|
-
return 0;
|
107
|
-
}
|