Skip to content

Commit 6f0219a

Browse files
committed
feat (UserProfileDB): changed fields from BLOB to TEXT
1 parent b6a70cd commit 6f0219a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/DIRAC/FrameworkSystem/DB/UserProfileDB.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class UserProfileDB(DB):
5151
"VOId": "INTEGER",
5252
"Profile": "VARCHAR(255) NOT NULL",
5353
"VarName": "VARCHAR(255) NOT NULL",
54-
"Data": "BLOB",
54+
"Data": "TEXT",
5555
"ReadAccess": 'VARCHAR(10) DEFAULT "USER"',
5656
"PublishAccess": 'VARCHAR(10) DEFAULT "USER"',
5757
},
@@ -260,7 +260,8 @@ def retrieveVarById(self, userIds, ownerIds, profileName, varName):
260260
return result
261261
data = result["Value"]
262262
if len(data) > 0:
263-
return S_OK(data[0][0].decode())
263+
# TODO: The decode is only needed in DIRAC v8.0.x while moving from BLOB -> TEXT
264+
return S_OK(data[0][0].decode() if isinstance(data[0][0], bytes) else data[0][0])
264265
return S_ERROR("No data for userIds %s profileName %s varName %s" % (userIds, profileName, varName))
265266

266267
def retrieveAllUserVarsById(self, userIds, profileName):
@@ -278,7 +279,12 @@ def retrieveAllUserVarsById(self, userIds, profileName):
278279
if not result["OK"]:
279280
return result
280281
data = result["Value"]
281-
return S_OK({k: v.decode() for k, v in data})
282+
try:
283+
# TODO: This is only needed in DIRAC v8.0.x while moving from BLOB -> TEXT
284+
allUserDataDict = {k: v.decode() for k, v in data}
285+
except AttributeError:
286+
allUserDataDict = {k: v for k, v in data}
287+
return S_OK(allUserDataDict)
282288

283289
def retrieveUserProfilesById(self, userIds):
284290
"""
@@ -289,12 +295,15 @@ def retrieveUserProfilesById(self, userIds):
289295
result = self._query(selectSQL)
290296
if not result["OK"]:
291297
return result
292-
data = result["Value"]
293298
dataDict = {}
294-
for profile, varName, data in data:
299+
for profile, varName, data in result["Value"]:
295300
if profile not in dataDict:
296301
dataDict[profile] = {}
297-
dataDict[profile][varName] = data.decode()
302+
try:
303+
# TODO: This is only needed in DIRAC v8.0.x while moving from BLOB -> TEXT
304+
dataDict[profile][varName] = data.decode()
305+
except AttributeError:
306+
dataDict[profile][varName] = data
298307
return S_OK(dataDict)
299308

300309
def retrieveVarPermsById(self, userIds, ownerIds, profileName, varName):

0 commit comments

Comments
 (0)