File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 5
5
import pytest
6
6
import sqlalchemy as sa
7
7
from flask import Flask
8
- from sqlalchemy .orm import joinedload
9
8
from werkzeug .exceptions import NotFound
10
9
11
10
from flask_sqlalchemy import SQLAlchemy
@@ -28,11 +27,11 @@ def test_get_or_404_kwargs(app: Flask) -> None:
28
27
db = SQLAlchemy (app )
29
28
30
29
class User (db .Model ):
31
- id = sa .Column (db .Integer , primary_key = True )
30
+ id = sa .Column (db .Integer , primary_key = True ) # type: ignore[var-annotated]
32
31
33
32
class Todo (db .Model ):
34
33
id = sa .Column (sa .Integer , primary_key = True )
35
- user_id = sa .Column (sa .ForeignKey (User .id ))
34
+ user_id = sa .Column (sa .ForeignKey (User .id )) # type: ignore[var-annotated]
36
35
user = db .relationship (User )
37
36
38
37
with app .app_context ():
@@ -41,7 +40,7 @@ class Todo(db.Model):
41
40
db .session .commit ()
42
41
43
42
with app .app_context ():
44
- item = db .get_or_404 (Todo , 1 , options = [joinedload (Todo .user )])
43
+ item = db .get_or_404 (Todo , 1 , options = [db . joinedload (Todo .user )])
45
44
assert item .user .id == 1
46
45
# one query with join, no second query when accessing relationship
47
46
assert len (get_recorded_queries ()) == 1
You can’t perform that action at this time.
0 commit comments