pending changes** to the object already existing in the Session. The
`ident` argument is a scalar or tuple of primary key column values in
the order of the table def's primary key columns.
+
+ DEPRECATED. Use query.populate_existing().get() instead.
"""
ret = self._extension.load(self, ident, **kwargs)
return self.iterate_instances(result, querycontext=querycontext)
def instances(self, cursor, *mappers_or_columns, **kwargs):
+ """Given a ResultProxy cursor as returned by connection.execute(), return an ORM result as a list.
+
+ e.g.::
+
+ result = engine.execute("select * from users")
+ users = session.query(User).instances(result)
+
+ """
return list(self.iterate_instances(cursor, *mappers_or_columns, **kwargs))
def iterate_instances(self, cursor, *mappers_or_columns, **kwargs):
+ """Given a ResultProxy cursor as returned by connection.execute(), return an ORM result as an iterator.
+
+ e.g.::
+
+ result = engine.execute("select * from users")
+ for u in session.query(User).iterate_instances(result):
+ print u
+
+ """
session = self.session
context = kwargs.pop('querycontext', None)
def get(self, class_, ident, **kwargs):
"""Return an instance of the object based on the given
identifier, or ``None`` if not found.
+
+ DEPRECATED. use session.query(class_).get(ident)
- The `ident` argument is a scalar or tuple of primary key
- column values in the order of the table def's primary key
- columns.
-
- The `entity_name` keyword argument may also be specified which
- further qualifies the underlying Mapper used to perform the
- query.
"""
-
entity_name = kwargs.pop('entity_name', None)
return self.query(class_, entity_name=entity_name).get(ident, **kwargs)
"""Return an instance of the object based on the given
identifier.
- If not found, raises an exception. The method will **remove
- all pending changes** to the object already existing in the
- ``Session``. The `ident` argument is a scalar or tuple of primary
- key columns in the order of the table def's primary key
- columns.
+ DEPRECATED. use session.query(class_).populate_existing().get(ident).
- The `entity_name` keyword argument may also be specified which
- further qualifies the underlying ``Mapper`` used to perform the
- query.
"""
-
entity_name = kwargs.pop('entity_name', None)
return self.query(class_, entity_name=entity_name).load(ident, **kwargs)