Skip to content

Commit 5ce560b

Browse files
Merge branch 'release/8.0.5'
2 parents 35867e4 + a166f49 commit 5ce560b

File tree

9 files changed

+78
-28
lines changed

9 files changed

+78
-28
lines changed

cpyint

lib/mysqlx/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
from .dbdoc import DbDoc
3636
from .errors import (Error, Warning, InterfaceError, DatabaseError,
3737
NotSupportedError, DataError, IntegrityError,
38-
ProgrammingError, OperationalError, InternalError)
38+
ProgrammingError, OperationalError, InternalError,
39+
PoolError)
3940
from .result import (ColumnMetaData, Row, Result, BufferingResult, RowResult,
4041
SqlResult, ColumnType)
4142
from .statement import (Statement, FilterableStatement, SqlStatement,
@@ -278,7 +279,7 @@ def get_session(*args, **kwargs):
278279
# mysqlx.errors
279280
"Error", "Warning", "InterfaceError", "DatabaseError", "NotSupportedError",
280281
"DataError", "IntegrityError", "ProgrammingError", "OperationalError",
281-
"InternalError",
282+
"InternalError", "PoolError",
282283

283284
# mysqlx.result
284285
"ColumnMetaData", "Row", "Result", "BufferingResult", "RowResult",

lib/mysqlx/config.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"""Implementation of Session Configuration"""
2525

2626
import os
27+
import sys
2728
import json
28-
import platform
2929

3030
from .compat import STRING_TYPES
3131
from .errors import OperationalError, InterfaceError
@@ -343,12 +343,14 @@ def items(self):
343343
return self._configs.items()
344344

345345
def _load_default_paths(self):
346-
if platform.system() == "Windows":
346+
if sys.platform.startswith("win"):
347347
self._usr_file = os.path.join(
348348
os.getenv("APPDATA"), "MySQLsessions.json")
349349
self._sys_file = os.path.join(
350350
os.getenv("PROGRAMDATA"), "MySQLsessions.json")
351-
elif platform.system() == "Linux":
351+
elif sys.platform.startswith("linux") or \
352+
sys.platform.startswith("darwin") or \
353+
sys.platform.startswith("sunos"):
352354
self._usr_file = os.path.join(
353355
os.getenv("HOME"), ".mysql", "sessions.json")
354356
self._sys_file = os.path.join(

lib/mysqlx/constants.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# MySQL Connector/Python - MySQL driver written in Python.
2-
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
33

44
# MySQL Connector/Python is licensed under the terms of the GPLv2
55
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -52,4 +52,4 @@ def create_enum(name, fields, values=None):
5252
Auth = create_enum("Auth", ("PLAIN", "EXTERNAL", "MYSQL41"),
5353
("plain", "external", "mysql41"))
5454

55-
__all__ = ["Algorithms", "Securities", "CheckOptions"]
55+
__all__ = ["Algorithms", "Securities", "CheckOptions", "SSLMode", "Auth"]

lib/mysqlx/expr.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,10 +1165,6 @@ def parse_table_select_projection(self):
11651165
if self.cur_token_type_is(TokenType.AS):
11661166
self.consume_token(TokenType.AS)
11671167
projection["alias"] = self.consume_token(TokenType.IDENT)
1168-
elif get_item_or_attr(projection["source"], "type") is \
1169-
mysqlxpb_enum("Mysqlx.Expr.Expr.Type.IDENT"):
1170-
self.pos -= 1
1171-
projection["alias"] = self.consume_token(TokenType.IDENT)
11721168
else:
11731169
projection["alias"] = fields[len(project_expr)]
11741170
project_expr.append(projection.get_message())

lib/mysqlx/protobuf/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"""This module contains the implementation of a helper class for MySQL X
2525
Protobuf messages."""
2626

27-
from mysqlx.compat import NUMERIC_TYPES, STRING_TYPES, BYTE_TYPES
27+
from mysqlx.compat import PY3, NUMERIC_TYPES, STRING_TYPES, BYTE_TYPES
28+
from mysqlx.helpers import encode_to_bytes
2829

2930

3031
_SERVER_MESSAGES_TUPLES = (
@@ -93,6 +94,8 @@
9394
# Mysqlx.Crud
9495
for key, val in mysqlx_crud_pb2.DataModel.items():
9596
_MESSAGES["Mysqlx.Crud.DataModel.{0}".format(key)] = val
97+
for key, val in mysqlx_crud_pb2.Find.RowLock.items():
98+
_MESSAGES["Mysqlx.Crud.Find.RowLock.{0}".format(key)] = val
9699
for key, val in mysqlx_crud_pb2.Order.Direction.items():
97100
_MESSAGES["Mysqlx.Crud.Order.Direction.{0}".format(key)] = val
98101
for key, val in mysqlx_crud_pb2.UpdateOperation.UpdateType.items():
@@ -230,8 +233,12 @@ def __setattr__(self, name, value):
230233
self._msg[name] = value.get_message() \
231234
if isinstance(value, Message) else value
232235
else:
233-
if isinstance(value, (NUMERIC_TYPES, STRING_TYPES, BYTE_TYPES)):
236+
if PY3 and isinstance(value, STRING_TYPES):
237+
setattr(self._msg, name, encode_to_bytes(value))
238+
elif isinstance(value, (NUMERIC_TYPES, STRING_TYPES, BYTE_TYPES)):
234239
setattr(self._msg, name, value)
240+
elif isinstance(value, list):
241+
getattr(self._msg, name).extend(value)
235242
elif isinstance(value, Message):
236243
getattr(self._msg, name).MergeFrom(value.get_message())
237244
else:

lib/mysqlx/protobuf/mysqlx_crud_pb2.py

Lines changed: 51 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/mysqlx/result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,10 +605,10 @@ def __getitem__(self, index):
605605
return self._fields[index]
606606

607607
def get_string(self, str_index):
608-
"""Returns the value if the index by string.
608+
"""Returns the value using the column name.
609609
610610
Args:
611-
str_index (str): The string index.
611+
str_index (str): The column name.
612612
"""
613613
int_index = self._resultset.index_of(str_index)
614614
if int_index >= len(self._fields):

tests/test_mysqlx_crud.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,11 @@ def test_find(self):
11631163
docs = result.fetch_all()
11641164
self.assertTrue("$.age + 100" in docs[0].keys())
11651165

1166+
# tests comma seperated fields
1167+
result = collection.find("$.age = 21").fields("$.age, $.name").execute()
1168+
docs = result.fetch_all()
1169+
self.assertEqual("Fred", docs[0]['$.name'])
1170+
11661171
self.schema.drop_collection(collection_name)
11671172

11681173
def test_modify(self):

0 commit comments

Comments
 (0)