@@ -238,6 +238,8 @@ dialect, **does not** support multirange datatypes.
238238.. versionadded :: 2.0.17 Added multirange support for the pg8000 dialect.
239239 pg8000 1.29.8 or greater is required.
240240
241+ .. versionadded :: 2.0.26 :class:`_postgresql.MultiRange` sequence added.
242+
241243The example below illustrates use of the :class: `_postgresql.TSMULTIRANGE `
242244datatype::
243245
@@ -260,6 +262,7 @@ datatype::
260262
261263 id: Mapped[int] = mapped_column(primary_key=True)
262264 event_name: Mapped[str]
265+ added: Mapped[datetime]
263266 in_session_periods: Mapped[List[Range[datetime]]] = mapped_column(TSMULTIRANGE)
264267
265268Illustrating insertion and selecting of a record::
@@ -294,6 +297,38 @@ Illustrating insertion and selecting of a record::
294297 a new list to the attribute, or use the :class: `.MutableList `
295298 type modifier. See the section :ref: `mutable_toplevel ` for background.
296299
300+ .. _postgresql_multirange_list_use :
301+
302+ Use of a MultiRange sequence to infer the multirange type
303+ """""""""""""""""""""""""""""""""""""""""""""""""""""""""
304+
305+ When using a multirange as a literal without specifying the type
306+ the utility :class: `_postgresql.MultiRange ` sequence can be used::
307+
308+ from sqlalchemy import literal
309+ from sqlalchemy.dialects.postgresql import MultiRange
310+
311+ with Session(engine) as session:
312+ stmt = select(EventCalendar).where(
313+ EventCalendar.added.op("<@")(
314+ MultiRange(
315+ [
316+ Range(datetime(2023, 1, 1), datetime(2013, 3, 31)),
317+ Range(datetime(2023, 7, 1), datetime(2013, 9, 30)),
318+ ]
319+ )
320+ )
321+ )
322+ in_range = session.execute(stmt).all()
323+
324+ with engine.connect() as conn:
325+ row = conn.scalar(select(literal(MultiRange([Range(2, 4)]))))
326+ print(f"{row.lower} -> {row.upper}")
327+
328+ Using a simple ``list `` instead of :class: `_postgresql.MultiRange ` would require
329+ manually setting the type of the literal value to the appropriate multirange type.
330+
331+ .. versionadded :: 2.0.26 :class:`_postgresql.MultiRange` sequence added.
297332
298333The available multirange datatypes are as follows:
299334
@@ -416,6 +451,8 @@ construction arguments, are as follows:
416451.. autoclass :: sqlalchemy.dialects.postgresql.AbstractRange
417452 :members: comparator_factory
418453
454+ .. autoclass :: sqlalchemy.dialects.postgresql.AbstractSingleRange
455+
419456.. autoclass :: sqlalchemy.dialects.postgresql.AbstractMultiRange
420457
421458
@@ -529,6 +566,9 @@ construction arguments, are as follows:
529566.. autoclass :: TSTZMULTIRANGE
530567
531568
569+ .. autoclass :: MultiRange
570+
571+
532572PostgreSQL SQL Elements and Functions
533573--------------------------------------
534574
0 commit comments