|
25 | 25 | import traceback
|
26 | 26 | import types
|
27 | 27 |
|
28 |
| -from bson import json_util, SON, Int64 |
| 28 | +from bson import json_util, Code, Decimal128, DBRef, SON, Int64, MaxKey, MinKey |
29 | 29 | from bson.binary import Binary
|
30 | 30 | from bson.objectid import ObjectId
|
31 |
| -from bson.py3compat import abc, integer_types, iteritems, text_type |
| 31 | +from bson.py3compat import abc, integer_types, iteritems, text_type, PY3 |
32 | 32 | from bson.regex import Regex, RE_TYPE
|
33 | 33 |
|
34 | 34 | from gridfs import GridFSBucket
|
@@ -286,22 +286,39 @@ def get_lsid_for_session(self, session_name):
|
286 | 286 | return self._session_lsids[session_name]
|
287 | 287 |
|
288 | 288 |
|
| 289 | +if not PY3: |
| 290 | + binary_types = (Binary,) |
| 291 | + long_types = (Int64, long) |
| 292 | + unicode_types = (unicode,) |
| 293 | +else: |
| 294 | + binary_types = (Binary, bytes) |
| 295 | + long_types = (Int64,) |
| 296 | + unicode_types = (str,) |
| 297 | + |
| 298 | + |
289 | 299 | BSON_TYPE_ALIAS_MAP = {
|
290 | 300 | # https://docs.mongodb.com/manual/reference/operator/query/type/
|
291 | 301 | # https://pymongo.readthedocs.io/en/stable/api/bson/index.html
|
292 | 302 | 'double': (float,),
|
293 | 303 | 'string': (text_type,),
|
294 | 304 | 'object': (abc.Mapping,),
|
295 | 305 | 'array': (abc.MutableSequence,),
|
296 |
| - 'binData': (Binary, bytes), |
| 306 | + 'binData': binary_types, |
| 307 | + 'undefined': (type(None),), |
297 | 308 | 'objectId': (ObjectId,),
|
298 | 309 | 'bool': (bool,),
|
299 | 310 | 'date': (datetime.datetime,),
|
300 | 311 | 'null': (type(None),),
|
301 | 312 | 'regex': (Regex, RE_TYPE),
|
| 313 | + 'dbPointer': (DBRef,), |
| 314 | + 'javascript': (*unicode_types, Code), |
| 315 | + 'symbol': unicode_types, |
| 316 | + 'javascriptWithScope': (*unicode_types, Code), |
302 | 317 | 'int': (int,),
|
303 |
| - 'long': (Int64,) |
304 |
| - # TODO: add all supported types |
| 318 | + 'long': (Int64,), |
| 319 | + 'decimal': (Decimal128,), |
| 320 | + 'maxKey': (MaxKey,), |
| 321 | + 'minKey': (MinKey,), |
305 | 322 | }
|
306 | 323 |
|
307 | 324 |
|
|
0 commit comments