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

Implements functions #10

Open
nicklayb opened this issue Jun 13, 2023 · 0 comments
Open

Implements functions #10

nicklayb opened this issue Jun 13, 2023 · 0 comments
Labels
enhancement New feature or request implementation Concerns a implementation (like Ecto)

Comments

@nicklayb
Copy link
Owner

nicklayb commented Jun 13, 2023

We would like a way to support common functions and user defined one. It might be useful to be able to use now() to refer to the current timestamp for instance or a way to get a contextual record.

Requirements

Support an identifier followed by parentheses like function("something") or now().

Goals

Being able to write get Event where start_time > now() that would convert to Database's NOW() function when querying.
Being able to write get Event where id = current_id() that would return a given value from the assign's map.

API proposal

Implement a function invoke/3 in EctoDefinition with the following signature

def invoke(function :: atom(), args :: list(String.t()), assigns :: map()) :: Ecto.Queryable.t()

Where assigns would be usual user provided assigns containing various properties (like role or permission for instance). Invoke could return a raw value or a queryable, like a fragment.

@nicklayb nicklayb added enhancement New feature or request implementation Concerns a implementation (like Ecto) labels Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request implementation Concerns a implementation (like Ecto)
Projects
Status: Todo
Development

No branches or pull requests

1 participant