Skip to content

feat: impl callback query/2#31

Merged
joeljuca merged 2 commits intomainfrom
feat/query-fn
Jun 6, 2025
Merged

feat: impl callback query/2#31
joeljuca merged 2 commits intomainfrom
feat/query-fn

Conversation

@joeljuca
Copy link
Owner

@joeljuca joeljuca commented Apr 5, 2025

Closes #28

@joeljuca
Copy link
Owner Author

joeljuca commented Jun 6, 2025

@greptileai pls review this for me

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Implements a new query/2 function that provides a flexible way to construct complex Ecto queries by accepting a query modification function, eliminating the need for numerous specific query functions.

  • Added query/2 implementation in lib/swiss_schema.ex that wraps results in {:ok, result} tuples and handles errors
  • Test cases in test/swiss_schema_test.exs verify function accepts custom query functions
  • Support for alternate Ecto repositories through options parameter
  • Function accepts a query transformer of type (Ecto.Query.t() -> Ecto.Query.t()) for query customization
  • Solves issue #28 by avoiding the need for parameter-specific query handling functions

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

2 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

@joeljuca
Copy link
Owner Author

joeljuca commented Jun 6, 2025

@greptileai hey – pls review this one again

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

Added query!/2 function as a non-error-tuple variant of query/2, providing a more direct way to execute Ecto queries with custom transformations.

  • Added bang variant query!/2 in lib/swiss_schema.ex that returns results directly or raises on error
  • Expanded test coverage in test/swiss_schema_test.exs to include error cases and exception handling
  • Consistent error handling for both Ecto.Query and Repo.all errors

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

@joeljuca joeljuca merged commit e31ee72 into main Jun 6, 2025
12 checks passed
@joeljuca joeljuca deleted the feat/query-fn branch June 6, 2025 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add function query/2

1 participant