File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 33import logging
44import os
55from typing import Any # noqa
6+ from typing import Optional
67
78from . import credentials as credentials_impl , table , scheme , pool
89from . import tracing
@@ -143,7 +144,7 @@ def __init__(
143144
144145 """
145146 self .endpoint = endpoint
146- self .database = database
147+ self .database = self . _maybe_add_slash ( database )
147148 self .ca_cert = ca_cert
148149 self .channel_options = channel_options
149150 self .secure_channel = _utilities .is_secure_protocol (endpoint )
@@ -169,7 +170,7 @@ def __init__(
169170 self .compression = compression
170171
171172 def set_database (self , database ):
172- self .database = database
173+ self .database = self . _maybe_add_slash ( database )
173174 return self
174175
175176 @classmethod
@@ -206,6 +207,15 @@ def _update_attrs_by_kwargs(self, **kwargs):
206207 )
207208 setattr (self , key , value )
208209
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+
209219
210220ConnectionParams = DriverConfig
211221
You can’t perform that action at this time.
0 commit comments