Skip to content

Commit

Permalink
Support mongodb+srv connection strings (#1513)
Browse files Browse the repository at this point in the history
#### Reference Issues/PRs
Closes #1512
  • Loading branch information
alexowens90 authored Apr 23, 2024
1 parent 655295c commit 891b867
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/arcticdb/adapters/mongo_library_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class MongoLibraryAdapter(ArcticLibraryAdapter):
@staticmethod
def supports_uri(uri: str) -> bool:
return uri.startswith("mongodb://") # mongo+srv:// support?
return uri.startswith("mongodb://") or uri.startswith("mongodb+srv://")

def __init__(self, uri: str, encoding_version: EncodingVersion, *args, **kwargs):
try:
Expand Down
6 changes: 6 additions & 0 deletions python/tests/integration/arcticdb/test_arctic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from arcticdb_ext.exceptions import InternalException, UserInputException
from arcticdb_ext.storage import NoDataFoundException
from arcticdb.exceptions import ArcticDbNotYetImplemented, LibraryNotFound, MismatchingLibraryOptions
from arcticdb.adapters.mongo_library_adapter import MongoLibraryAdapter
from arcticdb.arctic import Arctic
from arcticdb.options import LibraryOptions, EnterpriseLibraryOptions
from arcticdb import QueryBuilder
Expand Down Expand Up @@ -914,6 +915,11 @@ def test_s3_force_uri_lib_config_handling(s3_storage):
Arctic(s3_storage.arctic_uri + "&force_uri_lib_config=false")


@pytest.mark.parametrize("connection_string", ("mongodb://blah", "mongodb+srv://blah"))
def test_mongo_connection_string_format(connection_string):
assert MongoLibraryAdapter.supports_uri(connection_string)


# See test of same name in test_normalization.py for V1 API equivalent
def test_norm_failure_error_message(arctic_library):
lib = arctic_library
Expand Down

0 comments on commit 891b867

Please sign in to comment.