Merge branch 'master' into query-builder
This commit is contained in:
@@ -4,6 +4,7 @@ CHANGELOG
|
|||||||
* removed default values from all column types
|
* removed default values from all column types
|
||||||
* explicit primary key is required (automatic id removed)
|
* explicit primary key is required (automatic id removed)
|
||||||
* added validation on keyname types on .create()
|
* added validation on keyname types on .create()
|
||||||
|
* changed table_name to __table_name__, read_repair_chance to __read_repair_chance__, keyspace to __keyspace__
|
||||||
* changed internal implementation of model value get/set
|
* changed internal implementation of model value get/set
|
||||||
|
|
||||||
0.3.3
|
0.3.3
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ def create_table(model, create_missing_keyspace=True):
|
|||||||
|
|
||||||
qs += ['({})'.format(', '.join(qtypes))]
|
qs += ['({})'.format(', '.join(qtypes))]
|
||||||
|
|
||||||
with_qs = ['read_repair_chance = {}'.format(model.read_repair_chance)]
|
with_qs = ['read_repair_chance = {}'.format(model.__read_repair_chance__)]
|
||||||
|
|
||||||
_order = ["%s %s" % (c.db_field_name, c.clustering_order or 'ASC') for c in model._clustering_keys.values()]
|
_order = ["%s %s" % (c.db_field_name, c.clustering_order or 'ASC') for c in model._clustering_keys.values()]
|
||||||
if _order:
|
if _order:
|
||||||
|
|||||||
@@ -127,11 +127,12 @@ class BaseModel(object):
|
|||||||
|
|
||||||
#table names will be generated automatically from it's model and package name
|
#table names will be generated automatically from it's model and package name
|
||||||
#however, you can also define them manually here
|
#however, you can also define them manually here
|
||||||
table_name = None
|
__table_name__ = None
|
||||||
|
|
||||||
#the keyspace for this model
|
#the keyspace for this model
|
||||||
keyspace = None
|
__keyspace__ = None
|
||||||
read_repair_chance = 0.1
|
|
||||||
|
__read_repair_chance__ = 0.1
|
||||||
|
|
||||||
def __init__(self, **values):
|
def __init__(self, **values):
|
||||||
self._values = {}
|
self._values = {}
|
||||||
@@ -165,7 +166,7 @@ class BaseModel(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def _get_keyspace(cls):
|
def _get_keyspace(cls):
|
||||||
""" Returns the manual keyspace, if set, otherwise the default keyspace """
|
""" Returns the manual keyspace, if set, otherwise the default keyspace """
|
||||||
return cls.keyspace or DEFAULT_KEYSPACE
|
return cls.__keyspace__ or DEFAULT_KEYSPACE
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return self.as_dict() == other.as_dict()
|
return self.as_dict() == other.as_dict()
|
||||||
@@ -180,8 +181,8 @@ class BaseModel(object):
|
|||||||
otherwise, it creates it from the module and class name
|
otherwise, it creates it from the module and class name
|
||||||
"""
|
"""
|
||||||
cf_name = ''
|
cf_name = ''
|
||||||
if cls.table_name:
|
if cls.__table_name__:
|
||||||
cf_name = cls.table_name.lower()
|
cf_name = cls.__table_name__.lower()
|
||||||
else:
|
else:
|
||||||
camelcase = re.compile(r'([a-z])([A-Z])')
|
camelcase = re.compile(r'([a-z])([A-Z])')
|
||||||
ccase = lambda s: camelcase.sub(lambda v: '{}_{}'.format(v.group(1), v.group(2).lower()), s)
|
ccase = lambda s: camelcase.sub(lambda v: '{}_{}'.format(v.group(1), v.group(2).lower()), s)
|
||||||
@@ -341,7 +342,7 @@ class ModelMetaClass(type):
|
|||||||
db_map[col.db_field_name] = field_name
|
db_map[col.db_field_name] = field_name
|
||||||
|
|
||||||
#short circuit table_name inheritance
|
#short circuit table_name inheritance
|
||||||
attrs['table_name'] = attrs.get('table_name')
|
attrs['table_name'] = attrs.get('__table_name__')
|
||||||
|
|
||||||
#add management members to the class
|
#add management members to the class
|
||||||
attrs['_columns'] = column_dict
|
attrs['_columns'] = column_dict
|
||||||
|
|||||||
@@ -203,8 +203,8 @@ class TestModelClassFunction(BaseCassEngTestCase):
|
|||||||
class TestManualTableNaming(BaseCassEngTestCase):
|
class TestManualTableNaming(BaseCassEngTestCase):
|
||||||
|
|
||||||
class RenamedTest(cqlengine.Model):
|
class RenamedTest(cqlengine.Model):
|
||||||
keyspace = 'whatever'
|
__keyspace__ = 'whatever'
|
||||||
table_name = 'manual_name'
|
__table_name__ = 'manual_name'
|
||||||
|
|
||||||
id = cqlengine.UUID(primary_key=True)
|
id = cqlengine.UUID(primary_key=True)
|
||||||
data = cqlengine.Text()
|
data = cqlengine.Text()
|
||||||
|
|||||||
Reference in New Issue
Block a user