diff options
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql')
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/array.py | 3 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/dml.py | 27 |
2 files changed, 22 insertions, 8 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/array.py b/lib/sqlalchemy/dialects/postgresql/array.py index f30a409c7..abe17ea35 100644 --- a/lib/sqlalchemy/dialects/postgresql/array.py +++ b/lib/sqlalchemy/dialects/postgresql/array.py @@ -94,13 +94,12 @@ class array(expression.ClauseList, expression.ColumnElement): coercions.expect(roles.ExpressionElementRole, c) for c in clauses ] - super(array, self).__init__(*clauses, **kw) - self._type_tuple = [arg.type for arg in clauses] main_type = kw.pop( "type_", self._type_tuple[0] if self._type_tuple else sqltypes.NULLTYPE, ) + super(array, self).__init__(*clauses, **kw) if isinstance(main_type, ARRAY): self.type = ARRAY( diff --git a/lib/sqlalchemy/dialects/postgresql/dml.py b/lib/sqlalchemy/dialects/postgresql/dml.py index 48b180e81..09dbd9558 100644 --- a/lib/sqlalchemy/dialects/postgresql/dml.py +++ b/lib/sqlalchemy/dialects/postgresql/dml.py @@ -17,11 +17,31 @@ from ...sql.base import ColumnCollection from ...sql.dml import Insert as StandardInsert from ...sql.elements import ClauseElement from ...sql.expression import alias -from ...util.langhelpers import public_factory __all__ = ("Insert", "insert") + +def insert(table): + """Construct a PostgreSQL-specific variant :class:`_postgresql.Insert` + construct. + + .. container:: inherited_member + + The :func:`sqlalchemy.dialects.postgresql.insert` function creates + a :class:`sqlalchemy.dialects.postgresql.Insert`. This class is based + on the dialect-agnostic :class:`_sql.Insert` construct which may + be constructed using the :func:`_sql.insert` function in + SQLAlchemy Core. + + The :class:`_postgresql.Insert` construct includes additional methods + :meth:`_postgresql.Insert.on_conflict_do_update`, + :meth:`_postgresql.Insert.on_conflict_do_nothing`. + + """ + return Insert(table) + + SelfInsert = typing.TypeVar("SelfInsert", bound="Insert") @@ -183,11 +203,6 @@ class Insert(StandardInsert): return self -insert = public_factory( - Insert, ".dialects.postgresql.insert", ".dialects.postgresql.Insert" -) - - class OnConflictClause(ClauseElement): stringify_dialect = "postgresql" |
