mongo 0.15.1 → 0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE.txt +202 -0
- data/README.rdoc +15 -2
- data/Rakefile +17 -3
- data/bin/autoreconnect.rb +26 -0
- data/bin/fail_if_no_c.rb +11 -0
- data/lib/mongo.rb +9 -2
- data/lib/mongo/admin.rb +1 -1
- data/lib/mongo/collection.rb +86 -25
- data/lib/mongo/connection.rb +11 -0
- data/lib/mongo/constants.rb +15 -0
- data/lib/mongo/cursor.rb +176 -36
- data/lib/mongo/db.rb +84 -97
- data/lib/mongo/errors.rb +7 -1
- data/lib/mongo/types/objectid.rb +5 -0
- data/lib/mongo/util/byte_buffer.rb +12 -0
- data/lib/mongo/util/server_version.rb +69 -0
- data/lib/mongo/{message.rb → util/support.rb} +7 -4
- data/mongo-ruby-driver.gemspec +9 -86
- data/test/test_admin.rb +2 -2
- data/test/test_bson.rb +14 -0
- data/test/test_byte_buffer.rb +14 -0
- data/test/test_chunk.rb +4 -4
- data/test/test_collection.rb +107 -17
- data/test/test_connection.rb +13 -4
- data/test/test_cursor.rb +17 -14
- data/test/test_db.rb +7 -7
- data/test/test_db_api.rb +31 -19
- data/test/test_db_connection.rb +1 -1
- data/test/test_grid_store.rb +8 -8
- data/test/test_helper.rb +25 -0
- data/test/test_objectid.rb +11 -1
- data/test/test_slave_connection.rb +37 -0
- data/test/test_threading.rb +1 -1
- data/test/unit/cursor_test.rb +122 -0
- metadata +26 -46
- data/bin/mongo_console +0 -21
- data/bin/run_test_script +0 -19
- data/bin/standard_benchmark +0 -109
- data/lib/mongo/message/get_more_message.rb +0 -32
- data/lib/mongo/message/insert_message.rb +0 -37
- data/lib/mongo/message/kill_cursors_message.rb +0 -31
- data/lib/mongo/message/message.rb +0 -80
- data/lib/mongo/message/message_header.rb +0 -45
- data/lib/mongo/message/msg_message.rb +0 -29
- data/lib/mongo/message/opcodes.rb +0 -27
- data/lib/mongo/message/query_message.rb +0 -69
- data/lib/mongo/message/remove_message.rb +0 -37
- data/lib/mongo/message/update_message.rb +0 -38
- data/lib/mongo/query.rb +0 -118
- data/test/mongo-qa/admin +0 -26
- data/test/mongo-qa/capped +0 -22
- data/test/mongo-qa/count1 +0 -18
- data/test/mongo-qa/dbs +0 -22
- data/test/mongo-qa/find +0 -10
- data/test/mongo-qa/find1 +0 -15
- data/test/mongo-qa/gridfs_in +0 -16
- data/test/mongo-qa/gridfs_out +0 -17
- data/test/mongo-qa/indices +0 -49
- data/test/mongo-qa/remove +0 -25
- data/test/mongo-qa/stress1 +0 -35
- data/test/mongo-qa/test1 +0 -11
- data/test/mongo-qa/update +0 -18
- data/test/test_message.rb +0 -35
@@ -1,31 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
require 'mongo/message/message'
|
18
|
-
require 'mongo/message/opcodes'
|
19
|
-
|
20
|
-
module Mongo
|
21
|
-
|
22
|
-
class KillCursorsMessage < Message
|
23
|
-
|
24
|
-
def initialize(*cursors)
|
25
|
-
super(OP_KILL_CURSORS)
|
26
|
-
write_int(0)
|
27
|
-
write_int(cursors.length)
|
28
|
-
cursors.each { |c| write_long c }
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
require 'mongo/util/bson'
|
18
|
-
require 'mongo/util/byte_buffer'
|
19
|
-
|
20
|
-
module Mongo
|
21
|
-
|
22
|
-
class Message
|
23
|
-
|
24
|
-
HEADER_SIZE = 16 # size, id, response_to, opcode
|
25
|
-
|
26
|
-
@@class_req_id = 0
|
27
|
-
|
28
|
-
attr_reader :buf # for testing
|
29
|
-
|
30
|
-
def initialize(op)
|
31
|
-
@op = op
|
32
|
-
@message_length = HEADER_SIZE
|
33
|
-
@data_length = 0
|
34
|
-
@request_id = (@@class_req_id += 1)
|
35
|
-
@response_id = 0
|
36
|
-
@buf = ByteBuffer.new
|
37
|
-
|
38
|
-
@buf.put_int(16) # holder for length
|
39
|
-
@buf.put_int(@request_id)
|
40
|
-
@buf.put_int(0) # response_to
|
41
|
-
@buf.put_int(op)
|
42
|
-
end
|
43
|
-
|
44
|
-
def write_int(i)
|
45
|
-
@buf.put_int(i)
|
46
|
-
update_message_length
|
47
|
-
end
|
48
|
-
|
49
|
-
def write_long(i)
|
50
|
-
@buf.put_long(i)
|
51
|
-
update_message_length
|
52
|
-
end
|
53
|
-
|
54
|
-
def write_string(s)
|
55
|
-
BSON.serialize_cstr(@buf, s)
|
56
|
-
update_message_length
|
57
|
-
end
|
58
|
-
|
59
|
-
def write_doc(hash, check_keys=false)
|
60
|
-
@buf.put_array(BSON.new.serialize(hash, check_keys).to_a)
|
61
|
-
update_message_length
|
62
|
-
end
|
63
|
-
|
64
|
-
def to_a
|
65
|
-
@buf.to_a
|
66
|
-
end
|
67
|
-
|
68
|
-
def dump
|
69
|
-
@buf.dump
|
70
|
-
end
|
71
|
-
|
72
|
-
# Do not call. Private, but kept public for testing.
|
73
|
-
def update_message_length
|
74
|
-
pos = @buf.position
|
75
|
-
@buf.put_int(@buf.size, 0)
|
76
|
-
@buf.position = pos
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
require 'mongo/util/byte_buffer'
|
18
|
-
|
19
|
-
module Mongo
|
20
|
-
|
21
|
-
class MessageHeader
|
22
|
-
|
23
|
-
HEADER_SIZE = 16
|
24
|
-
|
25
|
-
def initialize()
|
26
|
-
@buf = ByteBuffer.new
|
27
|
-
end
|
28
|
-
|
29
|
-
def read_header(db)
|
30
|
-
@buf.rewind
|
31
|
-
@buf.put_array(db.receive_full(HEADER_SIZE).unpack("C*"))
|
32
|
-
raise "Short read for DB response header: expected #{HEADER_SIZE} bytes, saw #{@buf.size}" unless @buf.size == HEADER_SIZE
|
33
|
-
@buf.rewind
|
34
|
-
@size = @buf.get_int
|
35
|
-
@request_id = @buf.get_int
|
36
|
-
@response_to = @buf.get_int
|
37
|
-
@op = @buf.get_int
|
38
|
-
self
|
39
|
-
end
|
40
|
-
|
41
|
-
def dump
|
42
|
-
@buf.dump
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
require 'mongo/message/message'
|
18
|
-
require 'mongo/message/opcodes'
|
19
|
-
|
20
|
-
module Mongo
|
21
|
-
|
22
|
-
class MsgMessage < Message
|
23
|
-
|
24
|
-
def initialize(msg)
|
25
|
-
super(OP_MSG)
|
26
|
-
write_string(msg)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
module Mongo
|
18
|
-
OP_REPLY = 1 # reply. responseTo is set.
|
19
|
-
OP_MSG = 1000 # generic msg command followed by a string
|
20
|
-
OP_UPDATE = 2001 # update object
|
21
|
-
OP_INSERT = 2002
|
22
|
-
# GET_BY_OID = 2003
|
23
|
-
OP_QUERY = 2004
|
24
|
-
OP_GET_MORE = 2005
|
25
|
-
OP_DELETE = 2006
|
26
|
-
OP_KILL_CURSORS = 2007
|
27
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
require 'mongo/message/message'
|
18
|
-
require 'mongo/message/opcodes'
|
19
|
-
require 'mongo/util/conversions'
|
20
|
-
require 'mongo/util/ordered_hash'
|
21
|
-
|
22
|
-
module Mongo
|
23
|
-
class QueryMessage < Message
|
24
|
-
include Mongo::Conversions
|
25
|
-
|
26
|
-
attr_reader :query
|
27
|
-
|
28
|
-
def initialize(db_name, collection_name, query)
|
29
|
-
super(OP_QUERY)
|
30
|
-
@query = query
|
31
|
-
@collection_name = collection_name
|
32
|
-
write_int(0)
|
33
|
-
write_string("#{db_name}.#{collection_name}")
|
34
|
-
write_int(query.number_to_skip)
|
35
|
-
write_int(query.number_to_return)
|
36
|
-
sel = query.selector
|
37
|
-
if query.contains_special_fields
|
38
|
-
sel = OrderedHash.new
|
39
|
-
sel['query'] = query.selector
|
40
|
-
if query.order_by
|
41
|
-
order_by = query.order_by
|
42
|
-
sel['orderby'] = case order_by
|
43
|
-
when String then string_as_sort_parameters(order_by)
|
44
|
-
when Symbol then symbol_as_sort_parameters(order_by)
|
45
|
-
when Array then array_as_sort_parameters(order_by)
|
46
|
-
when Hash # Should be an ordered hash, but this message doesn't care
|
47
|
-
warn_if_deprecated(order_by)
|
48
|
-
order_by
|
49
|
-
else
|
50
|
-
raise InvalidSortValueError.new("illegal order_by: is a #{query.order_by.class.name}, must be String, Array, Hash, or OrderedHash")
|
51
|
-
end
|
52
|
-
end
|
53
|
-
sel['$hint'] = query.hint if query.hint && query.hint.length > 0
|
54
|
-
sel['$explain'] = true if query.explain
|
55
|
-
sel['$snapshot'] = true if query.snapshot
|
56
|
-
end
|
57
|
-
write_doc(sel)
|
58
|
-
write_doc(query.fields) if query.fields
|
59
|
-
end
|
60
|
-
|
61
|
-
def first_key(key)
|
62
|
-
@first_key = key
|
63
|
-
end
|
64
|
-
|
65
|
-
def to_s
|
66
|
-
"db.#{@collection_name}.#{@query}"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
require 'mongo/message/message'
|
18
|
-
require 'mongo/message/opcodes'
|
19
|
-
|
20
|
-
module Mongo
|
21
|
-
|
22
|
-
class RemoveMessage < Message
|
23
|
-
|
24
|
-
def initialize(db_name, collection_name, sel)
|
25
|
-
@collection_name = collection_name
|
26
|
-
super(OP_DELETE)
|
27
|
-
write_int(0)
|
28
|
-
write_string("#{db_name}.#{collection_name}")
|
29
|
-
write_int(0) # flags?
|
30
|
-
write_doc(sel)
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_s
|
34
|
-
"#{@collection_name}.clear()"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
require 'mongo/message/message'
|
18
|
-
require 'mongo/message/opcodes'
|
19
|
-
|
20
|
-
module Mongo
|
21
|
-
|
22
|
-
class UpdateMessage < Message
|
23
|
-
|
24
|
-
def initialize(db_name, collection_name, sel, obj, repsert)
|
25
|
-
@collection_name = collection_name
|
26
|
-
super(OP_UPDATE)
|
27
|
-
write_int(0)
|
28
|
-
write_string("#{db_name}.#{collection_name}")
|
29
|
-
write_int(repsert ? 1 : 0) # 1 if a repsert operation (upsert)
|
30
|
-
write_doc(sel)
|
31
|
-
write_doc(obj)
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_s
|
35
|
-
"db.#{@collection_name}.update(#{@sel.inspect}, #{@obj.inspect})"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/lib/mongo/query.rb
DELETED
@@ -1,118 +0,0 @@
|
|
1
|
-
# --
|
2
|
-
# Copyright (C) 2008-2009 10gen Inc.
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
# ++
|
16
|
-
|
17
|
-
require 'mongo/collection'
|
18
|
-
require 'mongo/message'
|
19
|
-
require 'mongo/types/code'
|
20
|
-
|
21
|
-
module Mongo
|
22
|
-
|
23
|
-
# A query against a collection. A query's selector is a hash. See the
|
24
|
-
# Mongo documentation for query details.
|
25
|
-
class Query
|
26
|
-
|
27
|
-
attr_accessor :number_to_skip, :number_to_return, :order_by, :snapshot
|
28
|
-
# If true, $explain will be set in QueryMessage that uses this query.
|
29
|
-
attr_accessor :explain
|
30
|
-
# Either +nil+ or a hash (preferably an OrderedHash).
|
31
|
-
attr_accessor :hint
|
32
|
-
attr_reader :selector # writer defined below
|
33
|
-
|
34
|
-
# sel :: A hash describing the query. See the Mongo docs for details.
|
35
|
-
#
|
36
|
-
# return_fields :: If not +nil+, a single field name or an array of
|
37
|
-
# field names. Only those fields will be returned.
|
38
|
-
# (Called :fields in calls to Collection#find.)
|
39
|
-
#
|
40
|
-
# number_to_skip :: Number of records to skip before returning
|
41
|
-
# records. Default is 0.
|
42
|
-
#
|
43
|
-
# number_to_return :: Max number of records to return. (Called :limit
|
44
|
-
# in calls to Collection#find.) Default is 0 (all
|
45
|
-
# records).
|
46
|
-
#
|
47
|
-
# order_by :: If not +nil+, specifies record sort order. May be a
|
48
|
-
# String, Hash, OrderedHash, or Array. If a string, the
|
49
|
-
# results will be ordered by that field in ascending
|
50
|
-
# order. If an array, it should be an array of field names
|
51
|
-
# which will all be sorted in ascending order. If a hash,
|
52
|
-
# it may be either a regular Hash or an OrderedHash. The
|
53
|
-
# keys should be field names, and the values should be 1
|
54
|
-
# (ascending) or -1 (descending). Note that if it is a
|
55
|
-
# regular Hash then sorting by more than one field
|
56
|
-
# probably will not be what you intend because key order
|
57
|
-
# is not preserved. (order_by is called :sort in calls to
|
58
|
-
# Collection#find.)
|
59
|
-
#
|
60
|
-
# hint :: If not +nil+, specifies query hint fields. Must be either
|
61
|
-
# +nil+ or a hash (preferably an OrderedHash). See
|
62
|
-
# Collection#hint.
|
63
|
-
def initialize(sel={}, return_fields=nil, number_to_skip=0, number_to_return=0, order_by=nil, hint=nil, snapshot=nil)
|
64
|
-
@number_to_skip, @number_to_return, @order_by, @hint, @snapshot =
|
65
|
-
number_to_skip, number_to_return, order_by, hint, snapshot
|
66
|
-
@explain = nil
|
67
|
-
self.selector = sel
|
68
|
-
self.fields = return_fields
|
69
|
-
end
|
70
|
-
|
71
|
-
# Set query selector hash. If sel is Code/string, it will be used as a
|
72
|
-
# $where clause. (See Mongo docs for details.)
|
73
|
-
def selector=(sel)
|
74
|
-
@selector = case sel
|
75
|
-
when nil
|
76
|
-
{}
|
77
|
-
when Code
|
78
|
-
{"$where" => sel}
|
79
|
-
when String
|
80
|
-
{"$where" => Code.new(sel)}
|
81
|
-
when Hash
|
82
|
-
sel
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Set fields to return. If +val+ is +nil+ or empty, all fields will be
|
87
|
-
# returned.
|
88
|
-
def fields=(val)
|
89
|
-
@fields = val
|
90
|
-
@fields = nil if @fields && @fields.empty?
|
91
|
-
end
|
92
|
-
|
93
|
-
def fields
|
94
|
-
case @fields
|
95
|
-
when String
|
96
|
-
{@fields => 1}
|
97
|
-
when Array
|
98
|
-
if @fields.length == 0
|
99
|
-
nil
|
100
|
-
else
|
101
|
-
h = {}
|
102
|
-
@fields.each { |field| h[field] = 1 }
|
103
|
-
h
|
104
|
-
end
|
105
|
-
else # nil, anything else
|
106
|
-
nil
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def contains_special_fields
|
111
|
-
@order_by || @explain || @hint || @snapshot
|
112
|
-
end
|
113
|
-
|
114
|
-
def to_s
|
115
|
-
"find(#{@selector.inspect})" + (@order_by ? ".sort(#{@order_by.inspect})" : "")
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|