CityOfPhiladelphia / carto-api-explorer

Generates API documentation for a dataset hosted on carto
https://cityofphiladelphia.github.io/carto-api-explorer/#incidents_part1_part2
2 stars 1 forks source link

Documentation issue around pattern matching using LIKE operator #16

Open santjosie opened 3 years ago

santjosie commented 3 years ago

When using the LIKE operator for pattern matching in a query, we can't pass the wildcard '%' in the URL. This throws an error. The documentation seems to suggest otherwise.

The example that I was looking at is the documentation for the end-point to the data in opa_properties_public.

https://cityofphiladelphia.github.io/carto-api-explorer/#opa_properties_public image

There are two issues here:

  1. The FROM clause is missing in this example
  2. For partial matches, using the wildcard '%' throws the error
    {
    "error": [
        "syntax error at or near \"%\""
    ]
    }

    Instead, the pattern matching can be done by issuing SELECT * FROM opa_properties_public WHERE mailing_address_1 LIKE 'OF PHIL%25'

timwis commented 3 years ago

Hey @santjosie good catch, and your solution is spot on. The reason this doesn't work is the % character has a special meaning in URLs: it's used to encode special characters (e.g. ^ is represented as %5E, and—a more commonly seen one—a space is represented as %20). As you've rightly pointed out, %25 is the encoded representation of a percentage character.

I agree the documentation should make this clearer. I don't maintain this repo anymore, but I'm sure the maintainers would be open to a pull request if you'd like to propose the specific change. You can edit this file and propose your changes be pulled in.