]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Create a storage field for arbitrary info on tables/columns; ticket #573
authorPaul Johnston <paj@pajhome.org.uk>
Tue, 6 Nov 2007 10:41:40 +0000 (10:41 +0000)
committerPaul Johnston <paj@pajhome.org.uk>
Tue, 6 Nov 2007 10:41:40 +0000 (10:41 +0000)
CHANGES
lib/sqlalchemy/schema.py

diff --git a/CHANGES b/CHANGES
index 7c0c77296e176f3ef6df06ea35be66f8acb362f2..d337995f2f60d82b9ad9720af1e8a3885a09eb0a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -36,6 +36,9 @@ CHANGES
     as well as to target result set columns originally bound to a 
     table or selectable to an aliased, "corresponding" expression.  The new
     rewrite features completely consistent and accurate behavior.
+
+  - Added a field ("info") for storing arbitrary data on schema items
+    [ticket:573]    
     
 - orm
   - eager loading with LIMIT/OFFSET applied no longer adds the primary 
index a7f24a211a19bafb66c33e4bbe8a5e9fa690f676..d05a8c13a38cfb8ab912b3059ccf55a9a6f620fd 100644 (file)
@@ -71,10 +71,17 @@ class SchemaItem(object):
         else:
             m = self.metadata
             return m and m.bind or None
-
-
     bind = property(lambda s:s._get_bind())
     
+    def info(self):
+        try:
+            return self._info
+        except AttributeError:
+            self._info = {}
+            return self._info
+    info = property(info)
+    
+
 def _get_table_key(name, schema):
     if schema is None:
         return name
@@ -156,6 +163,10 @@ class Table(SchemaItem, expression.TableClause):
             ``Table`` object.  Defaults to ``None`` which indicates all 
             columns should be reflected.
         
+          info
+            Defaults to {}: A space to store application specific data;
+            this must be a dictionary.
+
           mustexist
             Defaults to False: indicates that this Table must already
             have been defined elsewhere in the application, else an
@@ -199,6 +210,8 @@ class Table(SchemaItem, expression.TableClause):
         else:
             self.fullname = self.name
         self.owner = kwargs.pop('owner', None)
+        if kwargs.get('info'):
+            self._info = kwargs.pop('info')
         
         autoload = kwargs.pop('autoload', False)
         autoload_with = kwargs.pop('autoload_with', None)
@@ -383,6 +396,10 @@ class Column(SchemaItem, expression._ColumnClause):
             specify indexes with explicit names or indexes that
             contain multiple columns, use the ``Index`` construct instead.
 
+          info
+            Defaults to {}: A space to store application specific data;
+            this must be a dictionary.
+
           unique
             Defaults to False: indicates that this column contains a
             unique constraint, or if `index` is True as well,
@@ -430,6 +447,8 @@ class Column(SchemaItem, expression._ColumnClause):
         self.autoincrement = kwargs.pop('autoincrement', True)
         self.constraints = util.Set()
         self._foreign_keys = util.OrderedSet()
+        if kwargs.get('info'):
+            self._info = kwargs.pop('info')
         if kwargs:
             raise exceptions.ArgumentError("Unknown arguments passed to Column: " + repr(kwargs.keys()))