Skip to content

Commit

Permalink
fix: properly use multi name fields (#102)
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Funkhouser <[email protected]>
  • Loading branch information
golanglemonade authored Dec 13, 2024
1 parent 0f0cca2 commit a003a04
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions entfga/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func extractDefaultObjectType(val any) string {
return ""
}

schemaName = strings.ToLower(schemaName)
schemaName = strcase.SnakeCase(schemaName)

return strings.ReplaceAll(schemaName, "history", "")
return strings.Trim(strings.ReplaceAll(schemaName, "history", ""), "_")
}

// extractIDField gets the key that is used for the id field
Expand Down
5 changes: 5 additions & 0 deletions entfga/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func TestExtractDefaultObjectType(t *testing.T) {
input: "UserHistory",
expected: "user",
},
{
name: "valid schema name",
input: "ControlObjective",
expected: "control_objective",
},
{
name: "valid schema name, lowercase",
input: "userhistory",
Expand Down

0 comments on commit a003a04

Please sign in to comment.