]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add "index", "unique" to Column.merge() attrs
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 27 Sep 2022 02:31:05 +0000 (22:31 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 27 Sep 2022 02:31:05 +0000 (22:31 -0400)
Fixes: #8578
Change-Id: Ic79c19748d5bb00353d0a97f3a4b4f5eb9fdbb0c

lib/sqlalchemy/sql/schema.py
test/orm/declarative/test_typed_mapping.py
test/sql/test_metadata.py

index 56553710989b2b69a186b3cc8c3d8869434fd819..bbf78e6a1c18e2e252bcaa40aca342308b6cb352 100644 (file)
@@ -2327,6 +2327,12 @@ class Column(DialectKWArgs, SchemaItem, ColumnClause[_T]):
             new_onupdate = self.onupdate._copy()
             new_onupdate._set_parent(other)
 
+        if self.index and not other.index:
+            other.index = True
+
+        if self.unique and not other.unique:
+            other.unique = True
+
         for const in self.constraints:
             if not const._type_bound:
                 new_const = const._copy()
index 16cfee3407021b37cbe212ed1eba58668b7cb089..99c57e6ebe5e49456bcb4271fa2b098d47efd824 100644 (file)
@@ -666,6 +666,8 @@ class MappedColumnTest(fixtures.TestBase, testing.AssertsCompiledSQL):
         ("nullable", True),
         ("nullable", False),
         ("type", BigInteger()),
+        ("index", True),
+        ("unique", True),
         argnames="paramname, value",
     )
     @testing.combinations(True, False, argnames="optional")
index 7131476be277890ac83f2440fc23ffa3087c5f35..38255f9775a3e51d1781495b87810982c3cc477f 100644 (file)
@@ -4198,6 +4198,8 @@ class ColumnDefinitionTest(AssertsCompiledSQL, fixtures.TestBase):
         ("server_default", func.foo()),
         ("nullable", True),
         ("nullable", False),
+        ("index", True),
+        ("unique", True),
         ("type", BigInteger()),
         ("type", Enum("one", "two", "three", create_constraint=True)),
         argnames="paramname, value",