def test_datetime(self): t1 = DateTime() t2 = DateTime(timezone=False) t3 = DateTime(timezone=True) impl = self._fixture() is_(impl.compare_type(Column('x', t1), Column('x', t2)), False) is_(impl.compare_type(Column('x', t1), Column('x', t3)), True) is_(impl.compare_type(Column('x', t2), Column('x', t3)), True)
def test_numeric(self): t1 = Numeric(10, 5) t2 = Numeric(12, 5) t3 = DECIMAL(10, 5) t4 = DateTime impl = self._fixture() is_(impl.compare_type(Column('x', t3), Column('x', t1)), False) is_(impl.compare_type(Column('x', t3), Column('x', t2)), True) is_(impl.compare_type(Column('x', t3), Column('x', t4)), True)
def test_string(self): t1 = String(30) t2 = String(40) t3 = VARCHAR(30) t4 = Integer impl = self._fixture() is_(impl.compare_type(Column('x', t3), Column('x', t1)), False) is_(impl.compare_type(Column('x', t3), Column('x', t2)), True) is_(impl.compare_type(Column('x', t3), Column('x', t4)), True)
def test_typedec_to_nonstandard(self): class PasswordType(TypeDecorator): impl = VARBINARY def copy(self, **kw): return PasswordType(self.impl.length) def load_dialect_impl(self, dialect): if dialect.name == 'default': impl = sqlite.NUMERIC(self.length) else: impl = VARBINARY(self.length) return dialect.type_descriptor(impl) impl = self._fixture() impl.compare_type(Column('x', sqlite.NUMERIC(50)), Column('x', PasswordType(50)))
def test_typedec_to_nonstandard(self): class PasswordType(TypeDecorator): impl = VARBINARY def copy(self, **kw): return PasswordType(self.impl.length) def load_dialect_impl(self, dialect): if dialect.name == "default": impl = sqlite.NUMERIC(self.length) else: impl = VARBINARY(self.length) return dialect.type_descriptor(impl) impl = self._fixture() impl.compare_type( Column("x", sqlite.NUMERIC(50)), Column("x", PasswordType(50)) )
def test_integer(self): t1 = Integer() t2 = SmallInteger() t3 = BIGINT() t4 = String() t5 = INTEGER() t6 = BigInteger() impl = self._fixture() is_(impl.compare_type(Column('x', t5), Column('x', t1)), False) is_(impl.compare_type(Column('x', t3), Column('x', t1)), True) is_(impl.compare_type(Column('x', t3), Column('x', t6)), False) is_(impl.compare_type(Column('x', t3), Column('x', t2)), True) is_(impl.compare_type(Column('x', t5), Column('x', t2)), True) is_(impl.compare_type(Column('x', t1), Column('x', t4)), True)
def test_numeric_noprecision(self): t1 = Numeric() t2 = Numeric(scale=5) impl = self._fixture() is_(impl.compare_type(Column("x", t1), Column("x", t2)), False)