Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make searches on Meshmodel entities case insensitive #291

Merged
merged 1 commit into from
Apr 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions models/meshmodel/core/v1alpha1/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ func GetMeshModelComponents(db *database.Handler, f ComponentFilter) (c []Compon
Joins("JOIN category_dbs ON model_dbs.category_id = category_dbs.id") //
if f.Greedy {
if f.Name != "" && f.DisplayName != "" {
finder = finder.Where("component_definition_dbs.kind LIKE ? OR display_name LIKE ?", "%"+f.Name+"%", f.DisplayName+"%")
finder = finder.Where("component_definition_dbs.kind ILIKE ? OR display_name ILIKE ?", "%"+f.Name+"%", f.DisplayName+"%")
} else if f.Name != "" {
finder = finder.Where("component_definition_dbs.kind LIKE ?", "%"+f.Name+"%")
finder = finder.Where("component_definition_dbs.kind ILIKE ?", "%"+f.Name+"%")
} else if f.DisplayName != "" {
finder = finder.Where("component_definition_dbs.display_name LIKE ?", "%"+f.DisplayName+"%")
finder = finder.Where("component_definition_dbs.display_name ILIKE ?", "%"+f.DisplayName+"%")
}
} else {
if f.Name != "" {
Expand Down
2 changes: 1 addition & 1 deletion models/meshmodel/core/v1alpha1/relationship.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func GetMeshModelRelationship(db *database.Handler, f RelationshipFilter) (r []R
Joins("JOIN category_dbs ON model_dbs.category_id = category_dbs.id") //
if f.Kind != "" {
if f.Greedy {
finder = finder.Where("relationship_definition_dbs.kind LIKE ?", "%"+f.Kind+"%")
finder = finder.Where("relationship_definition_dbs.kind ILIKE ?", "%"+f.Kind+"%")
} else {
finder = finder.Where("relationship_definition_dbs.kind = ?", "%"+f.Kind+"%")
}
Expand Down
8 changes: 4 additions & 4 deletions models/meshmodel/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ func (rm *RegistryManager) GetModels(db *database.Handler, f types.Filter) []v1a
if mf, ok := f.(*v1alpha1.ModelFilter); ok {
if mf.Greedy {
if mf.Name != "" && mf.DisplayName != "" {
finder = finder.Where("model_dbs.name LIKE ? OR model_dbs.display_name LIKE ?", "%"+mf.Name+"%", "%"+mf.DisplayName+"%")
finder = finder.Where("model_dbs.name ILIKE ? OR model_dbs.display_name ILIKE ?", "%"+mf.Name+"%", "%"+mf.DisplayName+"%")
} else if mf.Name != "" {
finder = finder.Where("model_dbs.name LIKE ?", "%"+mf.Name+"%")
finder = finder.Where("model_dbs.name ILIKE ?", "%"+mf.Name+"%")
} else if mf.DisplayName != "" {
finder = finder.Where("model_dbs.display_name LIKE ?", "%"+mf.DisplayName+"%")
finder = finder.Where("model_dbs.display_name ILIKE ?", "%"+mf.DisplayName+"%")
}
} else {
if mf.Name != "" {
Expand Down Expand Up @@ -250,7 +250,7 @@ func (rm *RegistryManager) GetCategories(db *database.Handler, f types.Filter) [
if mf, ok := f.(*v1alpha1.CategoryFilter); ok {
if mf.Name != "" {
if mf.Greedy {
finder = finder.Where("name LIKE ?", "%"+mf.Name+"%")
finder = finder.Where("name ILIKE ?", "%"+mf.Name+"%")
} else {
finder = finder.Where("name = ?", mf.Name)
}
Expand Down