notum-cz / strapi-plugin-location

This plugin allows users to create location inputs and store latitude and longitude values as geometry types in a PostGIS database. It also provides functionality to filter items based on their location.
MIT License
24 stars 13 forks source link

Search not working in hyphenated content types #21

Closed Vaibhav-npc closed 1 year ago

Vaibhav-npc commented 1 year ago

Bug report

Describe the bug

Search within radius or exact search is not working when the content type has hyphen in the api url.

Works for below content type http://localhost:1338/api/samples?$location[samloc]=18.516726,73.856255,5000

Does not work when content type has hyphen in URL http://localhost:1338/api/sam-locs?$location[samloc]=18.516726,73.856255,5000

Steps to reproduce the behavior

  1. Create collection with display name as camel case or spaced, which will create hyphenated API ID.
  2. Add custom location field
  3. Create few entries in newly created collection with lat and long entries few hundreds km apart
  4. Try to search on location field within 50m or exact search, it will return all entries

Expected behavior

Location search should work independent of the collection name format.

System

Additional context

"@notum-cz/strapi-plugin-location": "^1.0.1", "@strapi/plugin-graphql": "^4.11.7", "@strapi/plugin-i18n": "4.11.7", "@strapi/plugin-users-permissions": "4.11.7", "@strapi/strapi": "4.11.7", "better-sqlite3": "8.0.1", "pg": "^8.11.2", "strapi-plugin-config-sync": "^1.1.2"

omikulcik commented 1 year ago

Hello @Vaibhav-npc, thank you for reporting this issue. I have submited a PR that should fix it. We will also release new version