Skip to content

Commit 6a87d27

Browse files
🔀 Merge google#292
1 parent 871c1c8 commit 6a87d27

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

python/sqlcommenter-python/google/cloud/sqlcommenter/django/middleware.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,16 @@ def __call__(self, execute, sql, params, many, context):
6767

6868
sql = add_sql_comment(
6969
sql,
70+
# For supported tags, see: https://cloud.google.com/sql/docs/mysql/using-query-insights#using-sql-commenter
7071
# Information about the controller.
7172
controller=resolver_match.view_name if resolver_match and with_controller else None,
7273
# route is the pattern that matched a request with a controller i.e. the regex
7374
# See https://docs.djangoproject.com/en/stable/ref/urlresolvers/#django.urls.ResolverMatch.route
7475
# getattr() because the attribute doesn't exist in Django < 2.2.
7576
route=getattr(resolver_match, 'route', None) if resolver_match and with_route else None,
76-
# app_name is the application namespace for the URL pattern that matches the URL.
77+
# application is the application namespace for the URL pattern that matches the URL.
7778
# See https://docs.djangoproject.com/en/stable/ref/urlresolvers/#django.urls.ResolverMatch.app_name
78-
app_name=(resolver_match.app_name or None) if resolver_match and with_app_name else None,
79+
application=(resolver_match.app_name or None) if resolver_match and with_app_name else None,
7980
# Framework centric information.
8081
framework=('django:%s' % django_version) if with_framework else None,
8182
# Information about the database and driver.

python/sqlcommenter-python/google/cloud/sqlcommenter/fastapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async def __call__(self, scope, receive, send):
7878
def _get_fastapi_info(fastapi_app: FastAPI, scope) -> dict:
7979
info = {
8080
"framework": 'fastapi:%s' % fastapi.__version__,
81-
"app_name": fastapi_app.title,
81+
"application": fastapi_app.title,
8282
}
8383

8484
route = _get_fastapi_route(fastapi_app, scope)

python/sqlcommenter-python/tests/django/tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,19 @@ def test_non_root_path(self):
106106
def test_app_path(self):
107107
with self.settings(SQLCOMMENTER_WITH_APP_NAME=True):
108108
query = self.get_query(path=reverse('app_urls:app-path'))
109-
self.assertIn("/*app_name='app_urls'", query)
109+
self.assertIn("/*application='app_urls'", query)
110110
self.assertIn("controller='app_urls%%3Aapp-path'", query)
111111
self.assertRoute('app-urls/app-path/', query)
112112

113113
def test_app_name_disabled(self):
114114
query = self.get_query(path=reverse('app_urls:app-path'))
115-
self.assertNotIn('app_name=', query)
115+
self.assertNotIn('application=', query)
116116

117117
def test_empty_app_name(self):
118118
"""An empty app_name is omitted."""
119119
with self.settings(SQLCOMMENTER_WITH_APP_NAME=True):
120120
query = self.get_query()
121-
self.assertNotIn("app_name=", query)
121+
self.assertNotIn("application=", query)
122122

123123
def test_db_driver(self):
124124
with self.settings(SQLCOMMENTER_WITH_DB_DRIVER=True):

python/sqlcommenter-python/tests/fastapi/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def client():
3232

3333
def test_get_fastapi_info_in_request_context(client):
3434
expected = {
35-
'app_name': 'SQLCommenter',
35+
'application': 'SQLCommenter',
3636
'controller': 'fastapi_info',
3737
'framework': 'fastapi:%s' % fastapi.__version__,
3838
'route': '/fastapi-info',
@@ -43,7 +43,7 @@ def test_get_fastapi_info_in_request_context(client):
4343

4444
def test_get_fastapi_info_in_404_error_context(client):
4545
expected = {
46-
'app_name': 'SQLCommenter',
46+
'application': 'SQLCommenter',
4747
'framework': 'fastapi:%s' % fastapi.__version__,
4848
}
4949
resp = client.get('/doesnt-exist')

0 commit comments

Comments
 (0)