-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(query-source): Fix query source relative filepath (#2717)
When generating the filename attribute for stack trace frames, the SDK uses the `filename_for_module` function. When generating the `code.filepath` attribute for query spans, the SDK does not use that function. Because of this inconsistency, code mappings that work with stack frames sometimes don't work with queries that come from the same files. This change makes sure that query sources use `filename_for_module`, so the paths are consistent.
- Loading branch information
Showing
15 changed files
with
223 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
import os | ||
import sys | ||
import pytest | ||
|
||
pytest.importorskip("asyncpg") | ||
pytest.importorskip("pytest_asyncio") | ||
|
||
# Load `asyncpg_helpers` into the module search path to test query source path names relative to module. See | ||
# `test_query_source_with_module_in_search_path` | ||
sys.path.insert(0, os.path.join(os.path.dirname(__file__))) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
async def execute_query_in_connection(query, connection): | ||
await connection.execute(query) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import os | ||
import sys | ||
import pytest | ||
|
||
pytest.importorskip("django") | ||
|
||
# Load `django_helpers` into the module search path to test query source path names relative to module. See | ||
# `test_query_source_with_module_in_search_path` | ||
sys.path.insert(0, os.path.join(os.path.dirname(__file__))) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.contrib.auth.models import User | ||
from django.http import HttpResponse | ||
from django.views.decorators.csrf import csrf_exempt | ||
|
||
|
||
@csrf_exempt | ||
def postgres_select_orm(request, *args, **kwargs): | ||
user = User.objects.using("postgres").all().first() | ||
return HttpResponse("ok {}".format(user)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
import os | ||
import sys | ||
import pytest | ||
|
||
pytest.importorskip("sqlalchemy") | ||
|
||
# Load `sqlalchemy_helpers` into the module search path to test query source path names relative to module. See | ||
# `test_query_source_with_module_in_search_path` | ||
sys.path.insert(0, os.path.join(os.path.dirname(__file__))) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
def add_model_to_session(model, session): | ||
session.add(model) | ||
session.commit() | ||
|
||
|
||
def query_first_model_from_session(model_klass, session): | ||
return session.query(model_klass).first() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters