diff options
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/base.py | 25 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/base.py | 26 |
2 files changed, 41 insertions, 10 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 00089815d..308e23bae 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -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)) diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 564fa50a9..2210ba408 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -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()``. """ |
