1. idank
  2. sqlalchemy

Commits

Mike Bayer  committed 1b12481

- The "objects" argument to session.flush() is deprecated.
State which represents the linkage between a parent and
child object does not support "flushed" status on
one side of the link and not the other, so supporting
this operation leads to misleading results.
[ticket:1315]

  • Participants
  • Parent commits 191365a
  • Branches default

Comments (0)

Files changed (3)

File CHANGES

View file
  • Ignore whitespace
 0.5.3
 =====
 - orm
+    - The "objects" argument to session.flush() is deprecated.
+      State which represents the linkage between a parent and
+      child object does not support "flushed" status on
+      one side of the link and not the other, so supporting
+      this operation leads to misleading results.
+      [ticket:1315]
+    
     - Query now implements __clause_element__() which produces
       its selectable, which means a Query instance can be accepted 
       in many SQL expressions, including col.in_(query), 

File lib/sqlalchemy/orm/session.py

View file
  • Ignore whitespace
         objects
           Optional; a list or tuple collection.  Restricts the flush operation
           to only these objects, rather than all pending changes.
+          Deprecated - this flag prevents the session from properly maintaining
+          accounting among inter-object relations and can cause invalid results.
 
         """
+
+        if objects:
+            util.warn_deprecated(
+                "The 'objects' argument to session.flush() is deprecated; "
+                "Please do not add objects to the session which should not yet be persisted.")
         
         if self._flushing:
             raise sa_exc.InvalidRequestError("Session is already flushing")

File test/orm/cascade.py

View file
  • Ignore whitespace
             Column("parent_id", Integer, ForeignKey("parent.id"))
         )
 
-
+    @testing.uses_deprecated()
     @testing.resolve_artifact_names
     def test_o2m_m2o(self):
         class Base(_base.ComparableEntity):
         assert c2 in sess and c2 not in sess.new
         assert b1 in sess and b1 in sess.new
 
+    @testing.uses_deprecated()
     @testing.resolve_artifact_names
     def test_circular_sort(self):
         """test ticket 1306"""