tarantool / tarantool-python

Python client library for Tarantool
https://www.tarantool.io
BSD 2-Clause "Simplified" License
100 stars 48 forks source link

types: support working with binary for Python 3 #211

Closed DifferentialOrange closed 2 years ago

DifferentialOrange commented 2 years ago

Merge after #213

This is a breaking change.

Before this patch, both bytes and str were encoded as mp_str. It was possible to work with utf and non-utf strings, but not with varbinary (mp_bin) [1]. This patch adds varbinary support for Python 3 by default. With Python 2 the behavior of the connector remains the same.

Before this patch:

Using bytes as key was not supported by several methods (delete, update, select).

After this patch:

Using bytes as key are now supported by all methods.

Thus, encoding="utf-8" connection may be used to work with utf-8 strings and varbinary and encodine=None connection may be used to work with non-utf-8 strings.

This patch does not add new restrictions (like "do not permit to use str in encoding=None mode because result may be confusing") to preserve current behavior (for example, using space name as str in schema get_space).

  1. https://github.com/tarantool/tarantool/issues/4201

Closes #105

DifferentialOrange commented 2 years ago

Note: test this PR rebased on #213 to ensure different msgpack package version compatiility

Totktonada commented 2 years ago

I glanced over the changes and I'm completely okay here. Please, finish the review with Sergey and proceed.