Skip to content

Add DateTimeRange support(TSRANGE) #42

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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