sqlalchemy.SmallInteger - python examples

Here are the examples of the python api sqlalchemy.SmallInteger taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

3 View Complete Implementation : test_fields.py
Copyright MIT License
Author : shosca
    def test_smallinteger_field(self):
        column = fields.SmallIntegerField()
        self.astertIsInstance(column.type, sa.SmallInteger)
        self.astertIsInstance(column.info["validators"][-2], django_validators.MinValueValidator)
        self.astertEqual(column.info["validators"][-2].limit_value, -32768)
        self.astertIsInstance(column.info["validators"][-1], django_validators.MaxValueValidator)
        self.astertEqual(column.info["validators"][-1].limit_value, 32767)

        form_field = meta.column_info(column).formfield()
        self.astertIsInstance(form_field, djangofields.IntegerField)

0 View Complete Implementation : 1f44305f4402_rate.py
Copyright Apache License 2.0
Author : EeOneDown
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('users', sa.Column('rate', sa.SmallInteger(), nullable=True))

0 View Complete Implementation : test_autogen_diffs.py
Copyright MIT License
Author : sqlalchemy
    @testing.combinations(
        (VARCHAR(30), String(30), False),
        (VARCHAR(30), String(40), True),
        (VARCHAR(30), Integer(), True),
        (DECIMAL(10, 5), Numeric(10, 5), False),
        (DECIMAL(10, 5), Numeric(12, 5), True),
        (DECIMAL(10, 5), DateTime(), True),
        (Numeric(), Numeric(scale=5), False),
        (INTEGER(), Integer(), False),
        (BIGINT(), Integer(), True),
        (BIGINT(), BigInteger(), False),
        (BIGINT(), SmallInteger(), True),
        (INTEGER(), SmallInteger(), True),
        (Integer(), String(), True),
        (DateTime(), DateTime(timezone=False), False),
        (DateTime(), DateTime(timezone=True), True),
        (DateTime(timezone=False), DateTime(timezone=True), True),
        id_="ssa",
        argnames="compare_from,compare_to,expected",
    )
    def test_compare_type(
        self, impl_fixture, compare_from, compare_to, expected
    ):

        is_(
            impl_fixture.compare_type(
                Column("x", compare_from), Column("x", compare_to)
            ),
            expected,
        )

0 View Complete Implementation : test_reflection.py
Copyright MIT License
Author : sqlalchemy
    def test_integer_types(self):
        specs = []
        for type_ in [
            mysql.TINYINT,
            mysql.SMALLINT,
            mysql.MEDIUMINT,
            mysql.INTEGER,
            mysql.BIGINT,
        ]:
            for display_width in [None, 4, 7]:
                for unsigned in [False, True]:
                    for zerofill in [None, True]:
                        kw = {}
                        if display_width:
                            kw["display_width"] = display_width
                        if unsigned is not None:
                            kw["unsigned"] = unsigned
                        if zerofill is not None:
                            kw["zerofill"] = zerofill

                        zerofill = bool(zerofill)
                        source_type = type_(**kw)

                        if display_width is None:
                            display_width = {
                                mysql.MEDIUMINT: 9,
                                mysql.SMALLINT: 6,
                                mysql.TINYINT: 4,
                                mysql.INTEGER: 11,
                                mysql.BIGINT: 20,
                            }[type_]

                        if zerofill:
                            unsigned = True

                        expected_type = type_(
                            display_width=display_width,
                            unsigned=unsigned,
                            zerofill=zerofill,
                        )
                        specs.append((source_type, expected_type))

        specs.extend(
            [
                (SmallInteger(), mysql.SMALLINT(display_width=6)),
                (Integer(), mysql.INTEGER(display_width=11)),
                (BigInteger, mysql.BIGINT(display_width=20)),
            ]
        )
        self._run_test(specs, ["display_width", "unsigned", "zerofill"])