Пример #1
0
 def test_column_type_conversion_timestamp(self):
     self._test_migrations(table_snapshots=[[self.table(column)]
                                            for column in [
                                                Timestamp(),
                                                Timestamptz(),
                                                Timestamp(),
                                            ]])
Пример #2
0
 def test_timestamp(self):
     Timestamp(default=None, null=True)
     Timestamp(default=TimestampNow())
     Timestamp(default=datetime.datetime.now())
     with self.assertRaises(ValueError):
         Timestamp(default="hello world")
     with self.assertRaises(ValueError):
         Timestamp(default=None, null=False)
Пример #3
0
class MegaTable(Table):
    """
    A table containing all of the column types, and different column kwargs.
    """

    bigint_col = BigInt()
    boolean_col = Boolean()
    bytea_col = Bytea()
    date_col = Date()
    foreignkey_col = ForeignKey(SmallTable)
    integer_col = Integer()
    interval_col = Interval()
    json_col = JSON()
    jsonb_col = JSONB()
    numeric_col = Numeric(digits=(5, 2))
    real_col = Real()
    double_precision_col = DoublePrecision()
    smallint_col = SmallInt()
    text_col = Text()
    timestamp_col = Timestamp()
    timestamptz_col = Timestamptz()
    uuid_col = UUID()
    varchar_col = Varchar()

    unique_col = Varchar(unique=True)
    null_col = Varchar(null=True)
    not_null_col = Varchar(null=False)
Пример #4
0
class MyTableDefault(Table):
    """
    A table containing all of the possible `default` arguments for
    `Timestamp`.
    """

    created_on = Timestamp(default=TimestampNow())
Пример #5
0
 def test_timestamp_column(self):
     self._test_migrations(
         table_snapshots=[[self.table(column)] for column in [
             Timestamp(),
             Timestamp(
                 default=datetime.datetime(year=2021, month=1, day=1)),
             Timestamp(default=datetime.datetime.now),
             Timestamp(default=datetime_default),
             Timestamp(null=True, default=None),
             Timestamp(null=False),
             Timestamp(index=True),
             Timestamp(index=False),
         ]],
         test_function=lambda x: all([
             x.data_type == "timestamp without time zone",
             x.is_nullable == "NO",
             x.column_default in ("now()", "CURRENT_TIMESTAMP"),
         ]),
     )
Пример #6
0
class MegaTable(Table):
    """
    A table containing all of the column types, and different column kwargs.
    """

    array_col = Array(Varchar())
    bigint_col = BigInt()
    boolean_col = Boolean()
    bytea_col = Bytea()
    date_col = Date()
    double_precision_col = DoublePrecision()
    integer_col = Integer()
    interval_col = Interval()
    json_col = JSON()
    jsonb_col = JSONB()
    numeric_col = Numeric(digits=(5, 2))
    real_col = Real()
    smallint_col = SmallInt()
    text_col = Text()
    timestamp_col = Timestamp()
    timestamptz_col = Timestamptz()
    uuid_col = UUID()
    varchar_col = Varchar()
Пример #7
0
class MyTable(Table):
    created_on = Timestamp()
Пример #8
0
 def test_timezone_aware(self):
     """
     Raise an error if a timezone aware datetime is given as a default.
     """
     with self.assertRaises(ValueError):
         Timestamp(default=datetime.datetime.now(tz=datetime.timezone.utc))
Пример #9
0
class Concert(Table):
    name = Varchar(index=True, index_method=IndexMethod.hash)
    time = Timestamp(
        index=True
    )  # Testing a column with the same name as a Postgres data type.
    capacity = Integer(index=False)
Пример #10
0
class MyTableDefault(Table):
    created_on = Timestamp(default=TimestampNow())
Пример #11
0
class Post(Table):
    name = Varchar(length=100)
    content = Text()
    created = Timestamp()
    rating = Integer()