Commit Graph

110 Commits

Author SHA1 Message Date
Shane Harvey
e4317d286b PYTHON-1508 Retryable commit/abort, has_error_label api
Retryable commitTransaction/abortTransaction.
Retry writes after certain writeConcernErrors.
Add has_error_label api.
Update unacknowledged write concern error messge.
Resync transaction tests and update test runner.
2018-06-07 14:39:52 -07:00
Shane Harvey
96aeb461f9 PYTHON-1545 Consider more errors retryable 2018-06-07 14:37:01 -07:00
Shane Harvey
3c2432d641 PYTHON-1543 Write operations should raise WTimeoutError 2018-05-23 19:57:00 -07:00
Bernie Hackett
ba7c95a9df PYTHON-1462 - Import ABCs from collections.abc 2018-02-12 19:42:44 -08:00
rdb
077fb2041a Allow fields to be a set (#347)
Add test cases for set and tuple projection arguments.
2018-02-12 11:33:36 -08:00
Bernie Hackett
507f954ed4 Update copyright dates 2017-12-01 17:23:39 -08:00
Shane Harvey
280efd2d72 PYTHON-1339 Generate a single message in _do_batched_write_command.
Ordered op_insert should check for errors on the last insert.
Use _Bulk API for Collection.insert.
Avoid sending acknowledged inserts as much as possible.
max_cmd_size already accounts for trailing null bytes.
2017-10-31 16:59:26 -04:00
Shane Harvey
f0b847adb8 PYTHON-1329 Refactor wire protocol message parsing.
Use _OpReply class instead of passing bytes around.
Remove unnecessary operation argument to receive message.
Move _first_batch to message.py to avoid circular import.
2017-10-09 15:11:50 -07:00
A. Jesse Jiryu Davis
2487e9b71f PYTHON-1332 - Session param for Collection methods 2017-09-11 17:46:44 -04:00
A. Jesse Jiryu Davis
0534596dc5 PYTHON-1362 - Add raw_batches option to find() 2017-08-25 15:24:16 -04:00
Bernie Hackett
26a4ae2c2f PYTHON-1113 - Fix _first_batch helper 2016-09-07 16:17:21 -07:00
Luke Lovett
b36a4345fd PYTHON-1101 - Support sending writeConcern for commands that write. 2016-08-11 14:02:22 -07:00
Bernie Hackett
53a7bea492 PYTHON-1022 - Drop support for Python 3.2
This change removes the u() helper from bson.py3compat
and all of its uses in the driver and tests. PyPy3 continues
to be supported since, even though it is based on python 3.2.5,
it has always supported the u string prefix.

The README and install docs are now explicit about PyPy(3) support.
2016-06-15 10:05:43 -07:00
aherlihy
10608144d6 PYTHON-658 - Support minPoolSize, maxIdleTimeMS 2016-06-14 14:37:06 +02:00
Luke Lovett
ecab1c9432 PYTHON-1090, PYTHON-1098 - Use sane codec options when reading write responses.
When reading a write response from the server, we now use the 'replace'
unicode_decode_error_handler and 'dict' as the document_class.
2016-06-01 13:34:18 -07:00
Bernie Hackett
740fc3c07a PYTHON-1033, PYTHON-1034 - Make protocol asserts exceptions
This change introduces a new exception, pymongo.errors.ProtocolError,
and uses it in place of asserts related to the wire protocol.
2016-05-19 17:18:00 -07:00
Bernie Hackett
6c4e4b5a81 PYTHON-1065 - Support 1 for batch_size with MongoDB >= 3.2 2016-03-07 17:48:54 -08:00
Luke Lovett
dde4a658b5 PYTHON-981 - Implement ReadConcern. 2015-11-18 14:12:28 -08:00
aherlihy
1a3aeea426 PYTHON-978 - Use find/getMore commands 2015-11-18 12:57:47 -08:00
Bernie Hackett
28885b25e8 PYTHON-952 - API improvements
This commit implements the following simplifications and improvements:

- The Subscriber ABC has been renamed to CommandListener
- The subscribe function has been renamed to register
- The COMMAND constant has been removed
- The get_subscribers function has been removed
- Command listeners can now be registered per MongoClient instance
  instead of just globally
2015-10-09 17:03:51 -07:00
Luke Lovett
b6182d0587 PYTHON-976 - Publish a CommandFailedEvent for arbitrary failures. 2015-10-07 11:08:05 -07:00
Bernie Hackett
a2a83c005f PYTHON-952 - Publish events for uses of _first_batch 2015-09-30 10:14:04 -07:00
Bernie Hackett
b80fa6d632 PYTHON-952 - Bulk write operations monitoring
This change adds monitoring of bulk write operations (i.e.
Collection.bulk_write, Collection.insert_many, Collection.insert with multiple
documents, Bulk.execute, etc.). It also fixes bugs in conversion of legacy
write results to write command result format and conversion of legacy queries
to find command documents. Finally, it adds an operation_id attribute to the
published events to tie related events together.
2015-09-10 09:10:19 -07:00
Bernie Hackett
414250b5ef PYTHON-952 - Minor docstring updates 2015-08-21 13:46:05 -07:00
Bernie Hackett
0e4f79c7c3 PYTHON-952 - Non-bulk write operation monitoring 2015-08-21 12:47:08 -07:00
Bernie Hackett
07d2199477 PYTHON-952 - Fix duration measurements.
We weren't including the time to decode responses in
a number of places. This commit also fixes an issue with
handling "cursor not found" errors from mongos versions
older than 2.4.
2015-08-12 14:04:21 -07:00
Bernie Hackett
fa4a6a39d3 PYTHON-952 - Query and getMore monitoring
This commit adds support for monitoring queries and getMore
operations, including getMore operations for command cursors
(e.g. aggregate cursor getMore). It also fixes a bug in duration
calculation.
2015-08-11 12:19:28 -07:00
Jason R. Coombs
1c806791a9 PYTHON-946 - Allow fields to be any sequence. 2015-06-15 14:43:44 -07:00
Bernie Hackett
5df17c2c63 PYTHON-818 - Remove unicode_literals future imports. 2015-03-27 10:08:11 -07:00
Bernie Hackett
aec685b374 Fix up copyright dates. 2015-03-25 11:55:02 -07:00
Bernie Hackett
e7c5cafc07 PYTHON-865 - Fix mongos $readPreference issues. 2015-03-23 19:07:15 -07:00
A. Jesse Jiryu Davis
edd513d3a2 Set SlaveOkay bit for list_indexes / index_information. 2015-03-21 17:28:49 -04:00
A. Jesse Jiryu Davis
8dd02f16ef Merge branch 'PYTHON-857-writable-max-wv'
* PYTHON-857-writable-max-wv:
  PYTHON-857 - Update C version of batch writes.
  PYTHON-857 - Fix SlaveOkay wire protocol bit for mapreduce.
  PYTHON-857 - Delete MongoClient._writable_max_wire_version().
  PYTHON-857 - Rename _get_socket_for_writes to _socket_for_writes.
  PYTHON-857 - Delete MongoClient._send_message.
  PYTHON-857 - Fix "not master" error handling.
  PYTHON-857 - Remove MongoClient.__check_gle_response.
  PYTHON-857 - Collection and Database use SocketInfo.command.
  PYTHON-857 - Complete wire-protocol race fix in Bulk API.
  PYTHON-857 - Simplify _Bulk.execute_no_results.
  PYTHON-857 - Pass socket to Collection._insert() etc.
  PYTHON-857 - Faster attribute access on SocketInfo.
  Remove MongoDB 2.5.x-specific code for retrieving an upserted _id.
  PYTHON-857 - Use SocketInfo, not MongoClient, in message.py.
  Obsolete comment about max write command size.
  PYTHON-857 - Fix server-reset logic.
  PYTHON-857 - Use client._get_socket_for_writes for write commands.
  PYTHON-857 - Use client._get_socket_for_writes for OP_UPDATE and OP_DELETE.
  PYTHON-857 - Use client._get_socket_for_writes for OP_INSERT.

Conflicts:
	pymongo/collection.py
	pymongo/helpers.py
2015-03-21 17:19:14 -04:00
A. Jesse Jiryu Davis
41bf0080cf PYTHON-857 - Collection and Database use SocketInfo.command. 2015-03-19 14:17:26 -04:00
A. Jesse Jiryu Davis
27c961a2ab PYTHON-857 - Use client._get_socket_for_writes for OP_INSERT.
We must get a socket *before* choosing whether to use write commands or legacy
writes. I will update the code in steps, getting a socket earlier and earlier
in the write path.

This commit gets a socket just before sending OP_INSERT in _do_batched_insert,
and temporarily disables the C version of _do_batched_insert.
2015-03-16 12:34:45 -04:00
Bernie Hackett
14ce3af058 PYTHON-861 - Implement list_indexes. 2015-03-16 08:00:58 -07:00
Bernie Hackett
9c4d01701b PYTHON-861 - Implement create_indexes. 2015-03-16 07:56:46 -07:00
Bernie Hackett
b71526a2da PYTHON-836 - Always set slaveOk bit for non-mongos direct connection. 2015-03-07 11:09:16 -08:00
Bernie Hackett
7164ba2f41 PYTHON-839 - Better validation error messages. 2015-02-25 10:14:29 -08:00
Bernie Hackett
c800cd18ad PYTHON-837 - Implement CRUD spec exception hierarchy. 2015-02-24 13:49:39 -08:00
Bernie Hackett
e7866dbd19 PYTHON-821 - Implement replace_one, update_one, and update_many. 2015-02-11 20:01:16 -08:00
Bernie Hackett
7416e6595c PYTHON-821 - Implement find_one_and_*.
This change also deprecates find_and_modify. Migrate
to find_one_and_delete, find_one_and_update, and/or
find_one_and_replace.
2015-02-10 12:09:47 -08:00
A. Jesse Jiryu Davis
9da835ab3d PYTHON-825 BSON API changes and internal options handling.
This change resolves four issues:

PYTHON-826 The new codec_options submodule is moved from pymongo to bson.

PYTHON-827 Use codec_options in BSON APIs.

Functions and methods of the bson module that accepted the options as_class,
tz_aware, and uuid_subtype now accept a codec_options parameter instead.

For example, the function definition for bson.decode_all changes from this:

def decode_all(data, as_class=dict, tz_aware=True,
               uuid_subtype=OLD_UUID_SUBTYPE)

to:

def decode_all(data, codec_options=CodecOptions())

The following functions are changed:

- decode_all
- decode_iter
- decode_file_iter

The following methods are changed:

- BSON.encode
- BSON.decode

This is a breaking change for any application that uses the BSON API directly
and changes any of the named parameter defaults. No changes are required for
applications that use the default values for these options. The behavior
remains the same.

PYTHON-828 Internal BSON module changes to support CodecOptions

The pure Python BSON module passes around a CodecOptions instance instead of
as_class, tz_aware, and uuid_subtype. C extensions pass these values around in
a struct.

PYTHON-801 Rename uuid_subtype to uuid_representation.
2015-02-05 23:09:23 -06:00
A. Jesse Jiryu Davis
a2c13090d8 PYTHON-826 Move codec_options submodule from pymongo to bson. 2015-02-02 09:38:49 -05:00
Bernie Hackett
1db2b0bfa5 PYTHON-800 - Clean up internal use of CodecOptions. 2014-12-23 19:52:31 -08:00
Bernie Hackett
a72d95b229 PYTHON-803 - Don't use Collection.find() for commands.
This change introduces a _command helper in the helpers
module, used by Database.command and various internal and
external command helpers instead of iterating a Cursor
instance.

This change also introduces a small incompatibility with
earier versions. The as_class and fields options have been
removed from Database.command. They were never documented
and only used by some internal helpers. This also removes
the documented uuid_subtype option. A forthcoming API
refactor will replace that functionality.
2014-12-16 14:37:43 -08:00
A. Jesse Jiryu Davis
2ba730722b PYTHON-526 Remove 'compile_re' option.
PyMongo now never attempts to compile BSON regular expressions as Python native
regular expressions.
2014-12-05 14:06:38 -05:00
A. Jesse Jiryu Davis
026757fd0d Unused imports. 2014-11-17 16:12:18 -05:00
A. Jesse Jiryu Davis
8e7caaacdb PYTHON-766 Fix KeyError when parsing certain mongos error responses. 2014-10-07 19:45:16 -04:00
A. Jesse Jiryu Davis
265490bd74 Unused helper function "shuffled()". 2014-09-25 16:34:15 -04:00