GSoC 2026: Add support for generate_series in PostgreSQL

Hi everyone,

I am very interested in the “Add support for generate_series in postgres” project for GSoC 2026. I have previously contributed to Django (fixed Trac #36964) and am excited to take on this ORM-focused challenge.

After researching the project idea and the previous forum discussions (especially the proposal by Simon Charette), I understand that this project is about providing the proper primitives for Set-Returning Functions (SRF) and Table-Valued Functions (TVF) rather than just a simple wrapper for generate_series.

My current strategy for the technical design involves a two-phase approach:

  1. Generic support for Composite Fields: I plan to build upon the recent work on CompositePrimaryKey (PR #17279 by Lily Foote) to implement a generic CompositeField. This “stepping stone” is crucial for teaching the ORM how to handle multiple columns returned by a single expression or function.

  2. The Relation Primitive & Table-Valued Functions: I intend to research a way to introduce a Relation expression that allows the ORM to treat a function call as a table source in FROM or JOIN clauses. This will involve modifying the Join class in django/db/models/sql/datastructures.py to accept an expression instead of just a table name string.

  3. Postgres-Specific Implementation: Once the generic primitives are in place, I will implement generate_series in contrib.postgres and explore support for LATERAL joins, which are the natural way to handle series that depend on other tables in the query.

I am currently diving deeper into how SQLCompiler.has_composite_fields and ColPairs work to understand how to best generalize them.

I would love to hear any initial feedback from the mentors on this direction or any specific technical constraints I should prioritize in my draft proposal.