Skip to content

Add DateTimeRange support(TSRANGE) #42

@razumeiko

Description

@razumeiko

Hi! Thanks for the plugin!
I found some issue when i was trying to use TSRANGE data type. If you will try to use example from SqlAlchemy docs:

from psycopg2.extras import DateTimeRange
from sqlalchemy.dialects.postgresql import TSRANGE

class RoomBooking(Base):

    __tablename__ = 'room_booking'

    room = Column(Integer(), primary_key=True)
    during = Column(TSRANGE())

booking = RoomBooking(
    room=101,
    during=DateTimeRange(datetime(2013, 3, 23), None)
)

You will receive error saying "'during' is of type tsrange but expression is of type character varying"

So it's required to explicitly cast the value: during = cast(DateTimeRange(datetime(2013, 3, 23), None), TSRANGE).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions