Skip to content

Commit

Permalink
Using uuidRepresentation as 'pythonLegacy'
Browse files Browse the repository at this point in the history
We are using 'python_legacy' instead of 'standard' UUID representation here because standard UUID representation should be used by new applications or applications that are encoding and/or decoding UUIDs in MongoDB for the first time. Python_legacy should be used by already existing applications using python drivers to encode and/or decode.

Ours is a python application that has already been storing data in databases for many months. It is NOT "encoding or decoding for the first time". If we used standard, although the unit tests might run, it would break in production.

Contains fix for the issue:
e-mission/e-mission-docs#856 (comment)
  • Loading branch information
swastis10 committed Mar 6, 2023
1 parent a6ac020 commit 9c683cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion emission/core/get_database.py
Expand Up @@ -34,7 +34,7 @@
db_name = "Stage_database"

print("Connecting to database URL "+url)
_current_db = MongoClient(url)[db_name]
_current_db = MongoClient(url, uuidRepresentation='pythonLegacy')[db_name]
#config_file.close()

def _get_current_db():
Expand Down
Expand Up @@ -204,7 +204,7 @@ def setupTestTrips(self, sectionsColl):

def testEntirePipeline(self):
self.setupTestTrips(self.SectionsColl)
self.setupTestTrips(MongoClient(edb.url).Backup_database.Stage_Sections)
self.setupTestTrips(MongoClient(edb.url, uuidRepresentation='pythonLegacy').Backup_database.Stage_Sections)
# Here, we only have 5 trips, so the pipeline looks for the backup training
# set instead, which fails because there is no backup. So let's copy data from
# the main DB to the backup DB to make this test pass
Expand Down

0 comments on commit 9c683cf

Please sign in to comment.