Python源码示例:sqlalchemy.dialects.postgresql.HSTORE
示例1
def test_postgresql_hstore_subtypes(self):
eq_ignore_whitespace(
autogenerate.render._repr_type(HSTORE(), self.autogen_context),
"postgresql.HSTORE(text_type=sa.Text())",
)
eq_ignore_whitespace(
autogenerate.render._repr_type(
HSTORE(text_type=String()), self.autogen_context
),
"postgresql.HSTORE(text_type=sa.String())",
)
eq_ignore_whitespace(
autogenerate.render._repr_type(
HSTORE(text_type=BYTEA()), self.autogen_context
),
"postgresql.HSTORE(text_type=postgresql.BYTEA())",
)
assert (
"from sqlalchemy.dialects import postgresql"
in self.autogen_context.imports
)
示例2
def test_should_postgresql_hstore_convert():
assert get_field(postgresql.HSTORE()).type == graphene.JSONString
示例3
def test_hstore(self):
self.test_hashable_flag(
postgresql.HSTORE(),
[{"a": "1", "b": "2", "c": "3"}, {"d": "4", "e": "5", "f": "6"}],
)
示例4
def setup(self):
metadata = MetaData()
self.test_table = Table(
"test_table",
metadata,
Column("id", Integer, primary_key=True),
Column("hash", HSTORE),
)
self.hashcol = self.test_table.c.hash
示例5
def test_ret_type_text(self):
col = column("x", HSTORE())
is_(col["foo"].type.__class__, Text)
示例6
def test_ret_type_custom(self):
class MyType(types.UserDefinedType):
pass
col = column("x", HSTORE(text_type=MyType))
is_(col["foo"].type.__class__, MyType)
示例7
def define_tables(cls, metadata):
Table(
"data_table",
metadata,
Column("id", Integer, primary_key=True),
Column("name", String(30), nullable=False),
Column("data", HSTORE),
)