Skip to content

support for new format indexes #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
msgpack-python>=0.4.0
pyyaml
3 changes: 2 additions & 1 deletion tarantool/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
__version__ = "0.6.1"


def connect(host="localhost", port=33013, user=None, password=None,
def connect(host="localhost", port=33013, user=None, password=None, socket=None,
encoding=ENCODING_DEFAULT):
'''
Create a connection to the Tarantool server.
Expand All @@ -43,6 +43,7 @@ def connect(host="localhost", port=33013, user=None, password=None,
return Connection(host, port,
user=user,
password=password,
socket=socket,
socket_timeout=SOCKET_TIMEOUT,
reconnect_max_attempts=RECONNECT_MAX_ATTEMPTS,
reconnect_delay=RECONNECT_DELAY,
Expand Down
6 changes: 4 additions & 2 deletions tarantool/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Connection(object):
def __init__(self, host, port,
user=None,
password=None,
socket=None,
socket_timeout=SOCKET_TIMEOUT,
reconnect_max_attempts=RECONNECT_MAX_ATTEMPTS,
reconnect_delay=RECONNECT_DELAY,
Expand Down Expand Up @@ -113,6 +114,7 @@ def __init__(self, host, port,
self.port = port
self.user = user
self.password = password
self.socket = socket
self.socket_timeout = socket_timeout
self.reconnect_delay = reconnect_delay
self.reconnect_max_attempts = reconnect_max_attempts
Expand All @@ -134,7 +136,7 @@ def close(self):
self._socket = None

def connect_basic(self):
if self.host == None:
if self.socket:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why're you doing this incompatible changes? use separate PR's for them.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'll send another PR for this. I thought this repo no longer active

self.connect_unix()
else:
self.connect_tcp()
Expand Down Expand Up @@ -168,7 +170,7 @@ def connect_unix(self):
if self._socket:
self._socket.close()
self._socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self._socket.connect(self.port)
self._socket.connect(self.socket)
except socket.error as e:
self.connected = False
raise NetworkError(e)
Expand Down
7 changes: 5 additions & 2 deletions tarantool/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ def __init__(self, index_row, space):
self.unique = index_row[4]
self.parts = []
if isinstance(index_row[5], (list, tuple)):
for k, v in index_row[5]:
self.parts.append((k, v))
for part in range(len(index_row[5])):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add tests for this part of code

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. But, I've changed format of parts to dict {'field': part[0], 'type': part[1]}, because for me parts doesn't matter. I don't use them. But this change brokes backward compatibility. So, I should do this by older way? I mean like this:

if isinstance(part, list):
    self.parts.append((part[0], part[1]))
else:
    self.parts.append((part['field'], part['type']))

if isinstance(part, list):
self.parts.append({'field': part[0], 'type': part[1]})
else:
self.parts.append(part)
else:
for i in range(index_row[5]):
self.parts.append((
Expand Down