Skip to content

Commit

Permalink
Change the default path for CRUD helpers to be lower case (#1276)
Browse files Browse the repository at this point in the history
If the structure contains a capital letter the default path will contain also the capital letter. Since path are case sensitive only on some servers it creates confusion.
To avoid it, the paths in the url's are converted to lower case.
  • Loading branch information
danysz authored Dec 19, 2024
1 parent d6306d6 commit 7e90187
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
12 changes: 9 additions & 3 deletions pkg/gofr/crud_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func Test_scanEntity(t *testing.T) {
entityType: reflect.TypeOf(userTestEntity{}),
primaryKey: "id",
tableName: "user_test_entity",
restPath: "userTestEntity",
restPath: "usertestentity",
constraints: map[string]gofrSql.FieldConstraints{"id": {AutoIncrement: true, NotNull: false},
"name": {AutoIncrement: false, NotNull: true},
},
Expand Down Expand Up @@ -180,10 +180,16 @@ func Test_getRestPath(t *testing.T) {
want: "custom_path",
},
{
name: "Test without RestPathOverrider interface",
name: "Test without RestPathOverrider interface - with lower case transformation",
object: &struct{}{},
structName: "TestStruct",
want: "TestStruct",
want: "teststruct",
},
{
name: "Test without RestPathOverrider interface",
object: &struct{}{},
structName: "test_struct",
want: "test_struct",
},
}
for _, tt := range tests {
Expand Down
2 changes: 1 addition & 1 deletion pkg/gofr/crud_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func getRestPath(object any, structName string) string {
return v.RestPath()
}

return structName
return strings.ToLower(structName)
}

func hasAutoIncrementID(constraints map[string]sql.FieldConstraints) bool {
Expand Down
34 changes: 16 additions & 18 deletions pkg/gofr/datasource/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,19 @@ Therefore, GoFr utilizes a pluggable approach for new datasources by separating

## Supported Datasources

| Datasource | Health-Check | Logs | Metrics | Traces | As Driver |
|-----------------|--------------|------|---------|--------|-----------|
| MySQL ||||| |
| Redis ||||| |
| PostgreSQL ||||| |
| MongoDB ||||||
| SQLite ||||| |
| BadgerDB ||||||
| Cassandra ||||||
| ClickHouse | |||||
| FTP | || | ||
| SFTP | || | ||
| Solr | |||||
| Dgraph ||||| |
| Azure Event Hub | ||| ||
| OpenTSDB ||| |||


| Datasource | Health-Check | Logs | Metrics | Traces | As Driver |
|------------------|:------------:|:----:|:-------:|:------:|:---------:|
| MySQL ||||| |
| REDIS ||||| |
| PostgreSQL ||||| |
| MongoDB ||||||
| SQLite ||||| |
| BadgerDB ||||||
| Cassandra ||||||
| ClickHouse | |||||
| FTP | || | ||
| SFTP | || | ||
| Solr | |||||
| DGraph ||||| |
| Azure Event Hubs | ||| ||
| OpenTSDB ||| |||

0 comments on commit 7e90187

Please sign in to comment.