incubator-bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From g..@apache.org
Subject svn commit: r1429875 - /incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py
Date Mon, 07 Jan 2013 16:16:02 GMT
Author: gjm
Date: Mon Jan  7 16:16:01 2013
New Revision: 1429875

URL: http://svn.apache.org/viewvc?rev=1429875&view=rev
Log:
adding ability to specify auto_increment field so that more schema can be generated - towards
#333 (from olemis)

Modified:
    incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py

Modified: incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py?rev=1429875&r1=1429874&r2=1429875&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py (original)
+++ incubator/bloodhound/trunk/bloodhound_dashboard/bhdashboard/model.py Mon Jan  7 16:16:01
2013
@@ -47,6 +47,7 @@ class ModelBase(object):
              'object_name':'WhatIWillCallMyselfInMessages',
              'key_fields':['id','id2'],
              'non_key_fields':['thing','anotherthing'],
+             'auto_inc_fields': ['id',],
              }
     """
     
@@ -232,7 +233,10 @@ class ModelBase(object):
     
     @classmethod
     def _get_schema(cls):
-        fields =  [Column(field) for field in cls._get_fields()]
+        """Generate schema from the class meta data"""
+        auto_inc =  cls._meta.get('auto_inc_fields', [])
+        fields =  [Column(f, auto_increment=f in auto_inc)
+                   for f in cls._get_fields()]
         return Table(cls._meta['table_name'], key=set(cls._meta['key_fields'] +
                             cls._meta['unique_fields'])) [fields]
 



Mime
View raw message