Roadmap¶
This page lists the features Ferro does not have yet, each with the workaround to use today. A filter on grouped results is the first gap; with the Author and Post models below, you filter the groups in Python after all():
from ferro import Field, Forward, Model, Relation, Reverse, connect, engines
class Author(Model):
id: int | None = Field(default=None, primary_key=True)
name: str
email: str = Field(unique=True)
posts: Relation[list["Post"]] = Reverse("author_id")
class Post(Model):
id: int | None = Field(default=None, primary_key=True)
title: str
published: bool = False
views: int = 0
author_id: int = Field(foreign_key=Author)
author: Relation[Author] = Forward("author_id")
from ferro import Field, Forward, Model, Relation, Reverse, connect, engines
class Author(Model):
id: Annotated[int | None, Field(primary_key=True)] = None
name: str
email: Annotated[str, Field(unique=True)]
posts: Relation[list["Post"]] = Reverse("author_id")
class Post(Model):
id: Annotated[int | None, Field(primary_key=True)] = None
title: str
published: bool = False
views: int = 0
author_id: Annotated[int, Field(foreign_key=Author)]
author: Relation[Author] = Forward("author_id")
Each block below runs inside async with engines.session():; see Connections › Sessions.
Query features¶
having()¶
Post-aggregation filtering for grouped queries does not exist, and where() rejects an aggregate predicate. Until having() ships (tracked here), filter the groups in Python:
from ferro import engines
async with engines.session():
rows = await Post.select(
lambda post: {"author_id": post.author_id, "total": post.views.sum()}
).all()
busy = [row.author_id for row in rows if row.total > 1000]
assert busy == [1]
The query sums views per author, and the list comprehension keeps the groups above 1000.
Typed record fields¶
A projected Row types its fields as Any on access, so row.total above does not check as int | None. Inferring a type per field from the selector is tracked here.
Reverse and many-to-many loading¶
include() loads forward relations in one statement. Loading Reverse collections and ManyToMany sets is not built: it needs a separate mechanism, a batched second query stitched onto the results. Until then, each awaited collection is its own query:
authors = await Author.all()
counts = [len(await author.posts.all()) for author in authors]
assert counts == [1, 1]
The comprehension issues one query per author. Filtering on reverse or many-to-many membership already works; see existence tests.
Cross-scope correlation in existence tests¶
An inner lambda cannot compare its column to the outer scope. Ferro rejects the comparison when the query is built instead of rendering it wrongly:
try:
Author.where(
lambda author: author.posts.exists(lambda post: post.views > author.id)
)
except TypeError as error:
assert "cross-scope correlation" in str(error)
else:
raise AssertionError("expected TypeError")
The TypeError names the comparison and says to compare against a value. Column-to-column correlation is tracked here.
ilike()¶
Case-insensitive pattern matching has no operator, and no issue tracks it yet. Store a lowercased copy of the value and match it with like().
.concat(), * and / in update recipes¶
An update recipe supports +, -, now and Postgres .merge(), but not list .concat(), * or /. No issue tracks them yet. Load the row, change it and save() it, or use raw SQL:
post = await Post.get(1)
post.views = post.views * 2
await post.save()
assert (await Post.get(1)).views == 3686
The multiplication happens in Python, so the read and the write are two statements. See Mutations for the recipes that run in the database.
Connections¶
disconnect()¶
There is no graceful pool shutdown for an application's shutdown hook; pools are cleaned up at process exit. No issue tracks it yet. In a test suite, ferro.reset_engine() tears the pools down.
Health checks¶
There is no check_connection() probe for readiness endpoints, and no issue tracks one yet. Run a trivial query and catch the failure:
A readiness endpoint treats an exception from this query as unhealthy.
Richer pool configuration¶
PoolConfig has max_connections, min_connections and settings_delivery. Acquire timeouts, idle timeouts and a maximum connection lifetime are future work, and no issue tracks them yet. See Connections.
Influencing priorities¶
None of this has a promised schedule. If a gap blocks you, say so on the issue tracker: a concrete use case is the strongest signal, and contributions are welcome.