Make sure column types with add'l init args are documented
This commit is contained in:
@@ -318,24 +318,17 @@ class Text(Column):
|
||||
"""
|
||||
Stores a UTF-8 encoded string
|
||||
"""
|
||||
|
||||
db_type = 'text'
|
||||
|
||||
min_length = None
|
||||
"""
|
||||
Sets the minimum length of this string, for validation purposes.
|
||||
Defaults to 1 if this is a ``required`` column. Otherwise, None.
|
||||
"""
|
||||
|
||||
max_length = None
|
||||
"""
|
||||
Sets the maximum length of this string, for validation purposes.
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.min_length = kwargs.pop('min_length', 1 if kwargs.get('required', False) else None)
|
||||
self.max_length = kwargs.pop('max_length', None)
|
||||
super(Text, self).__init__(*args, **kwargs)
|
||||
def __init__(self, min_length=None, max_length=None, **kwargs):
|
||||
"""
|
||||
:param int min_length: Sets the minimum length of this string, for validation purposes.
|
||||
Defaults to 1 if this is a ``required`` column. Otherwise, None.
|
||||
:param int max_lemgth: Sets the maximum length of this string, for validation purposes.
|
||||
"""
|
||||
self.min_length = min_length or (1 if kwargs.get('required', False) else None)
|
||||
self.max_length = max_length
|
||||
super(Text, self).__init__(**kwargs)
|
||||
|
||||
def validate(self, value):
|
||||
value = super(Text, self).validate(value)
|
||||
@@ -591,7 +584,7 @@ class Boolean(Column):
|
||||
|
||||
class Float(Column):
|
||||
"""
|
||||
Stores a 32-bit floating point value
|
||||
Stores a floating point value
|
||||
"""
|
||||
db_type = 'double'
|
||||
|
||||
@@ -765,6 +758,9 @@ class List(BaseContainerColumn):
|
||||
return bool(self.value)
|
||||
|
||||
def __init__(self, value_type, default=list, **kwargs):
|
||||
"""
|
||||
:param value_type: a column class indicating the types of the value
|
||||
"""
|
||||
return super(List, self).__init__(value_type=value_type, default=default, **kwargs)
|
||||
|
||||
def validate(self, value):
|
||||
|
@@ -50,7 +50,7 @@ Columns of all types are initialized by passing :class:`.Column` attributes to t
|
||||
|
||||
.. autoclass:: Boolean(**kwargs)
|
||||
|
||||
.. autoclass:: Counter(**kwargs)
|
||||
.. autoclass:: Counter
|
||||
|
||||
.. autoclass:: Date(**kwargs)
|
||||
|
||||
@@ -58,23 +58,17 @@ Columns of all types are initialized by passing :class:`.Column` attributes to t
|
||||
|
||||
.. autoclass:: Decimal(**kwargs)
|
||||
|
||||
.. autoclass:: Float(**kwargs)
|
||||
.. autoclass:: Float
|
||||
|
||||
.. autoclass:: Integer(**kwargs)
|
||||
|
||||
.. autoclass:: List(**kwargs)
|
||||
.. autoclass:: List
|
||||
|
||||
.. autoclass:: Map(**kwargs)
|
||||
.. autoclass:: Map
|
||||
|
||||
.. autoclass:: Set(**kwargs)
|
||||
.. autoclass:: Set
|
||||
|
||||
.. autoclass:: Text(**kwargs)
|
||||
|
||||
In addition to the :class:Column attributes, ``Text`` columns accept the following attributes for validation:
|
||||
|
||||
.. autoattribute:: min_length
|
||||
|
||||
.. autoattribute:: max_length
|
||||
.. autoclass:: Text
|
||||
|
||||
.. autoclass:: TimeUUID(**kwargs)
|
||||
|
||||
|
@@ -55,7 +55,7 @@ version = cassandra.__version__
|
||||
release = cassandra.__version__
|
||||
|
||||
autodoc_member_order = 'bysource'
|
||||
autoclass_content = 'class'
|
||||
autoclass_content = 'both'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
@@ -288,14 +288,14 @@ class TestBigInt(BaseCassEngTestCase):
|
||||
class TestText(BaseCassEngTestCase):
|
||||
|
||||
def test_min_length(self):
|
||||
#min len defaults to 1
|
||||
# not required defaults to 0
|
||||
col = Text()
|
||||
col.validate('')
|
||||
|
||||
col.validate('b')
|
||||
|
||||
#test not required defaults to 0
|
||||
Text(required=False).validate('')
|
||||
# required defaults to 1
|
||||
with self.assertRaises(ValidationError):
|
||||
Text(required=True).validate('')
|
||||
|
||||
#test arbitrary lengths
|
||||
Text(min_length=0).validate('')
|
||||
|
Reference in New Issue
Block a user