summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/postgresql/dml.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/dialects/postgresql/dml.py')
-rw-r--r--lib/sqlalchemy/dialects/postgresql/dml.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/dml.py b/lib/sqlalchemy/dialects/postgresql/dml.py
index 76dfafd04..bff61e173 100644
--- a/lib/sqlalchemy/dialects/postgresql/dml.py
+++ b/lib/sqlalchemy/dialects/postgresql/dml.py
@@ -10,6 +10,7 @@ from ... import util
from ...sql import coercions
from ...sql import roles
from ...sql import schema
+from ...sql.base import _exclusive_against
from ...sql.base import _generative
from ...sql.dml import Insert as StandardInsert
from ...sql.elements import ClauseElement
@@ -50,7 +51,16 @@ class Insert(StandardInsert):
"""
return alias(self.table, name="excluded").columns
+ _on_conflict_exclusive = _exclusive_against(
+ "_post_values_clause",
+ msgs={
+ "_post_values_clause": "This Insert construct already has "
+ "an ON CONFLICT clause established"
+ },
+ )
+
@_generative
+ @_on_conflict_exclusive
def on_conflict_do_update(
self,
constraint=None,
@@ -117,6 +127,7 @@ class Insert(StandardInsert):
)
@_generative
+ @_on_conflict_exclusive
def on_conflict_do_nothing(
self, constraint=None, index_elements=None, index_where=None
):