--- /dev/null
+.. change::
+ :tags: bug, postgresql, mysql
+ :tickets: 5729
+ :versions: 1.4.0b2
+
+ Fixed regression introduced in 1.3.2 for the PostgreSQL dialect, also
+ copied out to the MySQL dialect's feature in 1.3.18, where usage of a non
+ :class:`_schema.Table` construct such as :func:`_sql.text` as the argument
+ to :paramref:`_sql.Select.with_for_update.of` would fail to be accommodated
+ correctly within the PostgreSQL or MySQL compilers.
+
elif isinstance(elem, FromGrouping):
stack.append(elem.element)
elif isinstance(elem, ColumnClause):
- stack.append(elem.table)
+ if elem.table is not None:
+ stack.append(elem.table)
+ else:
+ yield elem
+ elif elem is not None:
+ yield elem
def extract_first_column_annotation(column, annotation_name):
from sqlalchemy import exc
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
+from sqlalchemy import literal_column
from sqlalchemy import Table
from sqlalchemy import testing
+from sqlalchemy import text
from sqlalchemy import update
from sqlalchemy.dialects.mysql import base as mysql
from sqlalchemy.exc import ProgrammingError
dialect=self.for_update_of_dialect,
)
+ def test_for_update_textual_of(self):
+ self.assert_compile(
+ self.table1.select(self.table1.c.myid == 7).with_for_update(
+ of=text("mytable")
+ ),
+ "SELECT mytable.myid, mytable.name, mytable.description "
+ "FROM mytable WHERE mytable.myid = %s "
+ "FOR UPDATE OF mytable",
+ dialect=self.for_update_of_dialect,
+ )
+
+ self.assert_compile(
+ self.table1.select(self.table1.c.myid == 7).with_for_update(
+ of=literal_column("mytable")
+ ),
+ "SELECT mytable.myid, mytable.name, mytable.description "
+ "FROM mytable WHERE mytable.myid = %s "
+ "FOR UPDATE OF mytable",
+ dialect=self.for_update_of_dialect,
+ )
+
class SkipLockedTest(fixtures.TablesTest):
__only_on__ = ("mysql", "mariadb")
"mytable_1.myid, mytable_1.name",
)
+ # ensure of=text() for of works
+ self.assert_compile(
+ table1.select(table1.c.myid == 7).with_for_update(
+ read=True, of=text("table1")
+ ),
+ "SELECT mytable.myid, mytable.name, mytable.description "
+ "FROM mytable WHERE mytable.myid = :myid_1 FOR UPDATE OF table1",
+ )
+
+ # ensure of=literal_column() for of works
+ self.assert_compile(
+ table1.select(table1.c.myid == 7).with_for_update(
+ read=True, of=literal_column("table1")
+ ),
+ "SELECT mytable.myid, mytable.name, mytable.description "
+ "FROM mytable WHERE mytable.myid = :myid_1 FOR UPDATE OF table1",
+ )
+
def test_for_update_of_w_limit_adaption_col_present(self):
table1 = table("mytable", column("myid"), column("name"))
"FOR UPDATE OF mytable_1, table2",
)
+ # ensure of=text() for of works
+ self.assert_compile(
+ table1.select(table1.c.myid == 7).with_for_update(
+ of=text("table1")
+ ),
+ "SELECT mytable.myid, mytable.name, mytable.description "
+ "FROM mytable WHERE mytable.myid = %(myid_1)s "
+ "FOR UPDATE OF table1",
+ )
+
+ # ensure literal_column of works
+ self.assert_compile(
+ table1.select(table1.c.myid == 7).with_for_update(
+ of=literal_column("table1")
+ ),
+ "SELECT mytable.myid, mytable.name, mytable.description "
+ "FROM mytable WHERE mytable.myid = %(myid_1)s "
+ "FOR UPDATE OF table1",
+ )
+
def test_for_update_with_schema(self):
m = MetaData()
table1 = Table(