File tree 1 file changed +12
-2
lines changed 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 3
3
import logging
4
4
import os
5
5
from typing import Any # noqa
6
+ from typing import Optional
6
7
7
8
from . import credentials as credentials_impl , table , scheme , pool
8
9
from . import tracing
@@ -143,7 +144,7 @@ def __init__(
143
144
144
145
"""
145
146
self .endpoint = endpoint
146
- self .database = database
147
+ self .database = self . _maybe_add_slash ( database )
147
148
self .ca_cert = ca_cert
148
149
self .channel_options = channel_options
149
150
self .secure_channel = _utilities .is_secure_protocol (endpoint )
@@ -169,7 +170,7 @@ def __init__(
169
170
self .compression = compression
170
171
171
172
def set_database (self , database ):
172
- self .database = database
173
+ self .database = self . _maybe_add_slash ( database )
173
174
return self
174
175
175
176
@classmethod
@@ -206,6 +207,15 @@ def _update_attrs_by_kwargs(self, **kwargs):
206
207
)
207
208
setattr (self , key , value )
208
209
210
+ def _maybe_add_slash (self , database : Optional [str ]) -> Optional [str ]:
211
+ if not database :
212
+ return database
213
+
214
+ if database .startswith ("/" ):
215
+ return database
216
+
217
+ return f"/{ database } "
218
+
209
219
210
220
ConnectionParams = DriverConfig
211
221
You can’t perform that action at this time.
0 commit comments