bitemyapp / esqueleto

New home of Esqueleto, please file issues so we can get things caught up!
BSD 3-Clause "New" or "Revised" License
372 stars 107 forks source link

Add support for substr() function #242

Open tysonzero opened 3 years ago

tysonzero commented 3 years ago

Currently it does not seem possible to slice up strings.

charukiewicz commented 3 years ago

It's pretty easy to add support for new functions in a similar manner to some of the existing (like length_, lower_, upper_, rtrim_, etc.). Here's how and where they're implemented:

https://github.com/bitemyapp/esqueleto/blob/a61f5527e8d8c2d4ce679b295578f9fe4dafd7cf/src/Database/Esqueleto/Internal/Internal.hs#L809-L846

Here's the general flow of how you can make changes:

  1. Fork the repo and clone it.
  2. Make the change locally.
  3. Run stack build --fast and stack haddock --fast to ensure the library and documentation builds correctly.
    • The Haddock html file will be created in the .stack-work/ directory within the repo after running the build, which you can open to verify that the docs are correct
  4. You can add the local copy of the project as a dependency to your own project to verify the new functions work, and/or update the tests.
  5. Push your changes back up to your fork and make a pull request into this repo.
belevy commented 3 years ago

This function isn't standardized across implementations so the function should go into the backend specific modules