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

APIv2: macros, SQL cleanup #4286

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

APIv2: macros, SQL cleanup #4286

wants to merge 12 commits into from

Conversation

macobo
Copy link
Contributor

@macobo macobo commented Jun 28, 2024

Cleanup PR.

QueryBuilder requires selected fields to be aliased via both field names passed to select_merge as well as setting selected_as. This PR introduces utility macros to reduce this sort of boilerplate.

It also moves more code under Plausible.Stats.SQL

@macobo macobo requested a review from ukutaht June 28, 2024 04:24
@macobo macobo changed the title APIv2: select_merge_as macro APIv2: macros, SQL cleanup Jun 28, 2024
@macobo macobo force-pushed the apiv2-breakdown-module-remove branch from 139e3ee to eac23c8 Compare June 28, 2024 06:45
@macobo macobo force-pushed the select_merge_as branch 2 times, most recently from 48aef7e to 9c8d16f Compare June 28, 2024 12:47
Base automatically changed from apiv2-breakdown-module-remove to master July 1, 2024 06:27
iex> wrap_expression([t], %{ foo: t.column }) |> expand_macro_once
"%{foo: dynamic([t], selected_as(t.column, :foo))}"
"""
defmacro wrap_expression(binding, map_literal) do
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this macro but the name feels quite generic. Can we come up with something better? My proposals would be with_alias, with_selected_as, wrap_alias or something along these lines.

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.

None yet

2 participants