Repository navigation
Conversation
This was referenced Oct 28, 2026
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Apply the parts of a query an adapter doesn't run in memory - Run single filter operators in the adapter and load whole paths in memory
Flo0807
force-pushed
the
feature/query-runtime
branch
from
November 13, 2026 09:46
6f7fbdd to
918e9e3
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack (merge in this order)
developStep 4 of the data source abstraction: adapters say which parts of a
Backpex.Querythey run, and Backpex applies the rest to the items in memory. An adapter that runs nothing only returns all items.supports?/2New optional callback
c:Backpex.Adapter.supports?/2, or the:supportsoption ofuse Backpex.Adapter(:allby default). Features::filter(and{:filter, operator}for single operators such as:containsor:exists),:search,:sort,:offset,:limit,:load,:count,:aggregate.The parts depend on each other in the order filter → search → sort → offset → limit.
Backpex.Resource.read/1gives the adapter the parts before the first unsupported one and applies that part and all later ones in memory, e.g. an adapter that sorts but can't filter gets neither. Relationships the in-memory parts read through paths are added to:load.count/1andaggregate/1are optional now: without them, or without support for the filter/search of the query, Backpex counts and aggregates the items ofread/1.In memory
Backpex.Query.apply_to/2andBackpex.Query.aggregate_items/2(inBackpex.Query.Runtime):nilkeeps nothing, not even negated),in,is_nil,contains/starts_with/ends_withwithignore_case, paths andexistsover loaded relationships; dates, times and decimals compare with their modulescontainsover all targets, values cast to text*_nulls_*directions; strings sort by code points:count,{:count | :sum | :avg | :min | :max, field}withwhere,nilfor no values,DecimalsumsBackpex.Adapters.MemoryKeeps the items of a LiveResource in an
Agent({Backpex.Adapters.Memory, name: ..., items: ...}), describes them with an (embedded)Ecto.Schemaand builds changesets like the Ecto adapter. It runs no part of a query, so it exercises the whole in-memory path. It passes the adapter conformance suite, which now reads throughBackpex.Resourcelike the views, andBackpex.Test.MemoryNoteLivecovers index (scope, search, sort, metric), show, form and delete.Docs
New guide
guides/adapters/custom-adapter.mdwith a read-only CSV adapter (its code was checked with a temporary test), a section in the v0.25 upgrade guide, andBackpex.Query/Backpex.Exprin one "Queries" module group.Review fixes
f422081:
supports: [{:filter, :<=}]) now runs the filters that only use them. Before, every filter and all later parts ran in memory.tags: [:category]), also for thewhereof aggregates; counts and aggregates only go to the adapter if it supports the operators of these expressions.inwithnilamong the values is unknown for other values, as in SQL.Backpex.Adapters.Memory.update_all/3changes the stored items instead of writing back the given ones.Testing
On f422081:
mix test: 1515 passed (188 doctests, 1327 tests)mix test --only e2e: 60 passedMIX_ENV=test mix lint: clean,mix docswithout warningsbun run test51 passed