Skip to content

Repository files navigation

Elixir CI License: MIT Hex version badge Hexdocs badge REUSE status

AshSql

Shared functionality for ecto-based sql data layers.

Installation

def deps do
  [
    {:ash_sql, "~> 0.7.6"}
  ]
end

Aggregate Strategies

AshSql.Implementation defaults aggregate planning to :lateral. SQL data layers can override aggregate_strategy/1 with :grouped when they need the SQLite-style grouped aggregate implementation.

The grouped strategy uses adapter-provided list aggregation. Implementations that select :grouped must implement grouped_list_aggregate/2 and return a list expression over the :ash_sql_grouped_aggregate_window window. The grouped strategy assumes SQLite-compatible SQL: list defaults are JSON-encoded, so list values must use a JSON list representation, and offset-only query aggregates use LIMIT -1. AshSQLite uses SQLite's JSON list representation for this callback.

The aggregate facade normalizes resource aggregates and SQL aliases before dispatch. Both strategies preserve the source binding and attachment path, so aggregates referenced through joined relationships attach to the related row. Alias reuse is scoped to that path and follows the existing filter/sort identity rules. Public aggregate names, including strings, are retained in results.

About

A library containing some shared Ecto-based sql data layer functionality.

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages