Skip to content

Commit 586aefa

Browse files
committed
Add alias for random_idgen
1 parent 0396b14 commit 586aefa

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

terminusdb_client/woqlquery/woql_query.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,6 +2240,32 @@ def idgen_random(self, prefix, uri):
22402240
self._cursor["uri"] = self._clean_node_value(uri)
22412241
return self
22422242

2243+
def random_idgen(self, prefix, uri):
2244+
"""Generates a unique ID with cryptographically secure random suffix (alias for idgen_random).
2245+
2246+
This is an alias for idgen_random() for compatibility with older code.
2247+
Uses base64 encoding to generate 16-character random IDs that are
2248+
guaranteed to be unique across executions.
2249+
2250+
Parameters
2251+
----------
2252+
prefix : str
2253+
A prefix for the IDs to be generated (e.g. "Person/")
2254+
uri : str
2255+
Variable name or output target for the generated ID
2256+
2257+
Returns
2258+
-------
2259+
WOQLQuery object
2260+
query object that can be chained and/or executed
2261+
2262+
Examples
2263+
-------
2264+
>>> WOQLQuery().random_idgen("Person/", "v:person_id").execute(client)
2265+
{'@type': 'api:WoqlResponse', 'api:status': 'api:success', 'api:variable_names': ['person_id'], 'bindings': [{'person_id': 'Person/aB3dEf9GhI2jK4lM'}], 'deletes': 0, 'inserts': 0, 'transaction_retry_count': 0}
2266+
"""
2267+
return self.idgen_random(prefix, uri)
2268+
22432269
def upper(self, left, right):
22442270
"""Changes a string to upper-case - input is in left, output in right
22452271

0 commit comments

Comments
 (0)