@@ -91,21 +91,21 @@ def inner(func: PostprocessCallable) -> PostprocessCallable:
91
91
@register ("sqlite" , "django.db.backends.sqlite3" )
92
92
def default_to_in_memory_db (parsed_config : DBConfig ) -> None :
93
93
# mimic sqlalchemy behaviour
94
- if parsed_config [ "NAME" ] == "" :
94
+ if not parsed_config . get ( "NAME" ) :
95
95
parsed_config ["NAME" ] = ":memory:"
96
96
97
97
98
98
@register ("oracle" , "django.db.backends.oracle" )
99
99
@register ("mssqlms" , "mssql" )
100
100
@register ("mssql" , "sql_server.pyodbc" )
101
101
def stringify_port (parsed_config : DBConfig ) -> None :
102
- parsed_config ["PORT" ] = str (parsed_config [ "PORT" ] )
102
+ parsed_config ["PORT" ] = str (parsed_config . get ( "PORT" , "" ) )
103
103
104
104
105
105
@register ("mysql" , "django.db.backends.mysql" )
106
106
@register ("mysql2" , "django.db.backends.mysql" )
107
107
def apply_ssl_ca (parsed_config : DBConfig ) -> None :
108
- options = parsed_config [ "OPTIONS" ]
108
+ options = parsed_config . get ( "OPTIONS" , {})
109
109
ca = options .pop ("ssl-ca" , None )
110
110
if ca :
111
111
options ["ssl" ] = {"ca" : ca }
@@ -119,7 +119,7 @@ def apply_ssl_ca(parsed_config: DBConfig) -> None:
119
119
@register ("timescale" , "timescale.db.backends.postgresql" )
120
120
@register ("timescalegis" , "timescale.db.backends.postgis" )
121
121
def apply_current_schema (parsed_config : DBConfig ) -> None :
122
- options = parsed_config [ "OPTIONS" ]
122
+ options = parsed_config . get ( "OPTIONS" , {})
123
123
schema = options .pop ("currentSchema" , None )
124
124
if schema :
125
125
options ["options" ] = f"-c search_path={ schema } "
@@ -237,7 +237,7 @@ def _convert_to_settings(
237
237
conn_health_checks : bool ,
238
238
disable_server_side_cursors : bool ,
239
239
ssl_require : bool ,
240
- test_options : Optional [dict ],
240
+ test_options : Optional [dict [ str , Any ] ],
241
241
) -> DBConfig :
242
242
settings : DBConfig = {
243
243
"CONN_MAX_AGE" : conn_max_age ,
0 commit comments