]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- postgres PGArray is a "mutable" type by default;
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 Mar 2008 19:31:33 +0000 (19:31 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 4 Mar 2008 19:31:33 +0000 (19:31 +0000)
when used with the ORM, mutable-style equality/
copy-on-write techniques are used to test for changes.

CHANGES
lib/sqlalchemy/databases/postgres.py

diff --git a/CHANGES b/CHANGES
index 93dfd62b29fafdc46ce690583e0dba8d16f99617..ff99249b9b35e0ac5969b8cb4872f16e6e27fb7a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -99,6 +99,10 @@ CHANGES
 
     - postgres TIMESTAMP renders correctly [ticket:981]
 
+    - postgres PGArray is a "mutable" type by default;
+      when used with the ORM, mutable-style equality/
+      copy-on-write techniques are used to test for changes.
+      
 0.4.3
 ------
 - sql
index 9f8e9860718dd60a2d461f95005f22d21cd772a4..19228f558e2d501aa761e0a747aa4d7d79e25db4 100644 (file)
@@ -113,11 +113,24 @@ class PGBoolean(sqltypes.Boolean):
     def get_col_spec(self):
         return "BOOLEAN"
 
-class PGArray(sqltypes.Concatenable, sqltypes.TypeEngine):
-    def __init__(self, item_type):
+class PGArray(sqltypes.MutableType, sqltypes.Concatenable, sqltypes.TypeEngine):
+    def __init__(self, item_type, mutable=True):
         if isinstance(item_type, type):
             item_type = item_type()
         self.item_type = item_type
+        self.mutable = mutable
+
+    def copy_value(self, value):
+        if self.mutable:
+            return list(value)
+        else:
+            return value
+
+    def compare_values(self, x, y):
+        return x == y
+
+    def is_mutable(self):
+        return self.mutable
 
     def dialect_impl(self, dialect, **kwargs):
         impl = self.__class__.__new__(self.__class__)