]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
doc updates partially from [ticket:1651]
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 17 Jan 2010 18:00:01 +0000 (18:00 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 17 Jan 2010 18:00:01 +0000 (18:00 +0000)
doc/build/reference/dialects/postgresql.rst
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/engine/base.py

index 7e00645d821802a07a6e32bfe5d5c65e848d1483..67a6c1e0bb8cb5d2054ede3a471b9d54a04e2a34 100644 (file)
@@ -3,6 +3,54 @@ PostgreSQL
 
 .. automodule:: sqlalchemy.dialects.postgresql.base
 
+PostgresSQL Column Types
+------------------------
+
+.. autoclass:: ARRAY
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: BIT
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: BYTEA
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: CIDR
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: DOUBLE_PRECISION
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: ENUM
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: INET
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: INTERVAL
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: MACADDR
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: REAL
+    :members: __init__
+    :show-inheritance:
+
+.. autoclass:: UUID
+    :members: __init__
+    :show-inheritance:
+
+
 psycopg2 Notes
 --------------
 
index 00089815d76740dfd3d3782b82ed77b02fa8cfd1..308e23bae83082b9473c2ae2ac421826c83c95c8 100644 (file)
@@ -65,8 +65,6 @@ option to the Index constructor::
 
   Index('my_index', my_table.c.id, postgresql_where=tbl.c.value > 10)
 
-
-
 """
 
 import re
@@ -129,6 +127,27 @@ class ARRAY(sqltypes.MutableType, sqltypes.Concatenable, sqltypes.TypeEngine):
     __visit_name__ = 'ARRAY'
     
     def __init__(self, item_type, mutable=True):
+        """Construct an ARRAY.
+
+        E.g.::
+
+          Column('myarray', ARRAY(Integer))
+
+        Arguments are:
+
+        :param item_type: The data type of items of this array. Note that dimensionality is
+          irrelevant here, so multi-dimensional arrays like ``INTEGER[][]``, are constructed as
+          ``ARRAY(Integer)``, not as ``ARRAY(ARRAY(Integer))`` or such. The type mapping figures
+          out on the fly
+
+        :param mutable: Defaults to True: specify whether lists passed to this class should be
+          considered mutable.  If so, generic copy operations (typically used by the ORM) will
+          shallow-copy values.
+          
+        """
+        if isinstance(item_type, ARRAY):
+            raise ValueError("Do not nest ARRAY types; ARRAY(basetype) "
+                            "handles multi-dimensional arrays of basetype")
         if isinstance(item_type, type):
             item_type = item_type()
         self.item_type = item_type
@@ -903,7 +922,7 @@ class PGDialect(default.DefaultDialect):
             if coltype:
                 coltype = coltype(*args, **kwargs)
                 if is_array:
-                    coltype = PGArray(coltype)
+                    coltype = ARRAY(coltype)
             else:
                 util.warn("Did not recognize type '%s' of column '%s'" %
                           (attype, name))
index 564fa50a949cb7c859969e91b80655dfc05d3804..2210ba40837b6d876ba27f6a8d60411a768059c2 100644 (file)
@@ -173,7 +173,7 @@ class Dialect(object):
         """Transform a generic type to a dialect-specific type.
 
         Dialect classes will usually use the
-        :func:`~sqlalchemy.types.adapt_type` method in the types module to
+        :func:`~sqlalchemy.types.adapt_type` function in the types module to
         make this job easy.
 
         The returned result is cached *per dialect class* so can
@@ -581,6 +581,19 @@ class ExecutionContext(object):
 
         raise NotImplementedError()
 
+    def get_rowcount(self):
+        """Return the number of rows produced (by a SELECT query)
+        or affected (by an INSERT/UPDATE/DELETE statement).
+
+        Note that this row count may not be properly implemented 
+        in some dialects; this is indicated by the 
+        ``supports_sane_rowcount`` and ``supports_sane_multi_rowcount``
+        dialect attributes.
+        
+        """
+
+        raise NotImplementedError()
+
 
 class Compiled(object):
     """Represent a compiled SQL or DDL expression.
@@ -1767,13 +1780,12 @@ class ResultProxy(object):
         uses and is not intended to provide the number of rows
         present from a SELECT.
         
-        Additionally, this value is only meaningful if the
-        dialect's supports_sane_rowcount flag is True for
-        single-parameter executions, or supports_sane_multi_rowcount
-        is true for multiple parameter executions - otherwise
-        results are undefined.
+        Note that this row count may not be properly implemented
+        in some dialects; this is indicated by
+         :meth:`~sqlalchemy.engine.base.ResultProxy.supports_sane_rowcount()` and
+         :meth:`~sqlalchemy.engine.base.ResultProxy.supports_sane_multi_rowcount()`.
         
-        rowcount may not work at this time for a statement
+        ``rowcount()`` also may not work at this time for a statement
         that uses ``returning()``.
         
         """