return _column_descriptions(self, legacy=True)
+ @util.deprecated(
+ "2.0",
+ "The :meth:`_orm.Query.instances` method is deprecated and will "
+ "be removed in a future release. "
+ "Use the Select.from_statement() method or aliased() construct in "
+ "conjunction with Session.execute() instead.",
+ )
def instances(
self,
result_proxy: CursorResult[Any],
# the statement where it would be able to create an adapter
def go():
with testing.expect_deprecated(
- r"Using the Query.instances\(\) method without a context"
+ r"Using the Query.instances\(\) method without a context",
+ r"The Query.instances\(\) method is deprecated and will be "
+ r"removed in a future release.",
+ raise_on_any_unexpected=True,
):
result = list(
q.options(
def go():
with testing.expect_deprecated(
- r"Using the Query.instances\(\) method without a context"
+ r"Using the Query.instances\(\) method without a context",
+ r"The Query.instances\(\) method is deprecated and will be "
+ r"removed in a future release.",
+ raise_on_any_unexpected=True,
):
result = list(
q.options(
from sqlalchemy.orm import joinedload
from sqlalchemy.orm import Load
from sqlalchemy.orm import load_only
+from sqlalchemy.orm import loading
from sqlalchemy.orm import relationship
from sqlalchemy.orm import strategy_options
from sqlalchemy.orm import subqueryload
ctx = sess.query(User)._compile_context()
def go():
- result = list(sess.query(User).instances(r, ctx))
+ result = loading.instances(r, ctx).scalars().unique()
+ result = list(result)
eq_(result, self.static.user_address_result)
self.sql_count_(4, go)
ctx = sess.query(User)._compile_context()
def go():
- result = list(sess.query(User).instances(r, ctx))
+ result = loading.instances(r, ctx).scalars().unique()
+ result = list(result)
eq_(result, self.static.user_all_result)
self.assert_sql_count(testing.db, go, 6)