def test_uuid(self): UUID(default=None, null=True) UUID(default=UUID4()) UUID(default=uuid.uuid4()) with self.assertRaises(ValueError): UUID(default="hello world") with self.assertRaises(ValueError): UUID(default=None, null=False)
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)
def test_uuid_column(self): self._test_migrations( table_snapshots=[[self.table(column)] for column in [ UUID(), UUID(default="ecf338cd-6da7-464c-b31e-4b2e3e12f0f0"), UUID( default=uuid.UUID("2dfc9c47-adab-4692-b804-f692f3b0fc07")), UUID(default=uuid.uuid4), UUID(default=uuid_default), UUID(default=UUID4()), UUID(null=True, default=None), UUID(null=False), UUID(index=True), UUID(index=False), ]], test_function=lambda x: all([ x.data_type == "uuid", x.is_nullable == "NO", x.column_default == "uuid_generate_v4()", ]), )
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()
class Concert(Table): uuid = UUID(primary_key=True) name = Varchar() customers = M2M( LazyTableReference("CustomerToConcert", module_path=__name__))
class Band(Table): pk = UUID(primary=True, key=True) name = Varchar() manager = ForeignKey(Manager)
class Manager(Table): pk = UUID(primary=True, key=True) name = Varchar()
class MyTablePrimaryKeyUUID(Table): pk = UUID(null=False, primary_key=True) name = Varchar()
class MyTable(Table): uuid = UUID()
class Movie(Table): id = UUID(primary_key=True) name = Varchar(length=100, required=True) rating = Integer()