Skip to content

Commit 9c51ce6

Browse files
Fix label name transformation to valid gremlin name
1 parent 7c5256c commit 9c51ce6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

forward_engineering/api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ const generateVariables = variables => {
147147
};
148148

149149
const generateVertex = (collection, vertexData) => {
150-
const vertexName = collection.collectionName;
150+
const vertexName = transformToValidGremlinName(collection.collectionName);
151151
const propertiesScript = addPropertiesScript(collection, vertexData);
152152

153153
return `${graphName}.addV(${JSON.stringify(vertexName)})${propertiesScript}`;
@@ -169,7 +169,7 @@ const generateVertices = (collections, jsonData) => {
169169
}
170170

171171
const generateEdge = (from, to, relationship, edgeData) => {
172-
const edgeName = relationship.name;
172+
const edgeName = transformToValidGremlinName(relationship.name);
173173
const propertiesScript = addPropertiesScript(relationship, edgeData);
174174

175175
return `${from}.addE(${JSON.stringify(edgeName)}).\n${DEFAULT_INDENT}to(${to})${propertiesScript}`;
@@ -535,7 +535,7 @@ const transformToValidGremlinName = name => {
535535
return DEFAULT_NAME;
536536
}
537537

538-
const nameWithoutSpecialCharacters = name.replace(/[\s`~!@#%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '_');
538+
const nameWithoutSpecialCharacters = name.replace(/[\f\t\n\v\r`~!@#%^&*_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '_');
539539
const startsFromDigit = nameWithoutSpecialCharacters.match(/^[0-9].*$/);
540540

541541
if (startsFromDigit) {

0 commit comments

Comments
 (0)