Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: pycassa/pycassa
base: master
...
head fork: justecorruptio/pycassa
compare: master
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 11 additions and 4 deletions.
  1. +6 −4 pycassa/columnfamily.py
  2. +5 −0 pycassa/marshal.py
View
10 pycassa/columnfamily.py
@@ -451,9 +451,6 @@ def _unpack_name(self, b, is_supercol_name=False):
(b, d_type))
def _pack_value(self, value, col_name):
- if value is None:
- return
-
if not self.autopack_values:
if not isinstance(value, basestring):
raise TypeError("A str or unicode column value was expected for " +
@@ -461,6 +458,9 @@ def _pack_value(self, value, col_name):
% (str(col_name), value.__class__.__name__, str(value)))
return value
+ if value is None:
+ return ''
+
packed_col_name = self._pack_name(col_name, False)
packer = self._column_validators.packers.get(packed_col_name, self._default_value_packer)
try:
@@ -476,8 +476,10 @@ def _unpack_value(self, value, col_name):
unpacker = self._column_validators.unpackers.get(col_name, self._default_value_unpacker)
try:
return unpacker(value)
- except struct.error:
+ except (struct.error, ValueError), e:
d_type = self.column_validators.get(col_name, self.default_validation_class)
+ if value == '' and not marshal.is_string_type(d_type):
+ return None
raise TypeError("%s cannot be converted to a type matching %s" %
(value, d_type))
View
5 pycassa/marshal.py
@@ -30,6 +30,11 @@ def make_packer(fmt_string):
'DateType', 'BooleanType', 'UUIDType', 'Int32Type',
'DecimalType')
+_STRING_TYPES = ('BytesType', 'UTF8Type', 'AsciiType')
+
+def is_string_type(typestr):
+ return typestr in _STRING_TYPES
+
def extract_type_name(typestr):
if typestr is None:
return 'BytesType'

No commit comments for this range

Something went wrong with that request. Please try again.