def All(other, arrexpr, operator=operators.eq):
"""A synonym for the :meth:`.ARRAY.Comparator.all` method.
This method is legacy and is here for backwards-compatibility.
.. seealso::
:func:`.expression.all_`
"""
return arrexpr.all(other, operator)
python类ARRAY的实例源码
def __init__(self, clauses, **kw):
super(array, self).__init__(*clauses, **kw)
self.type = ARRAY(self.type)
def ancestor_of(self, other):
if isinstance(other, list):
return self.op('@>')(expression.cast(other, ARRAY(LtreeType)))
else:
return self.op('@>')(other)
def descendant_of(self, other):
if isinstance(other, list):
return self.op('<@')(expression.cast(other, ARRAY(LtreeType)))
else:
return self.op('<@')(other)
def lquery(self, other):
if isinstance(other, list):
return self.op('?')(expression.cast(other, ARRAY(LQUERY)))
else:
return self.op('~')(other)
def _repeated_value(type_):
if isinstance(type_, ARRAY):
if isinstance(type_.item_type, sa.Integer):
return [0]
elif isinstance(type_.item_type, sa.String):
return [u'a']
elif isinstance(type_.item_type, sa.Numeric):
return [Decimal('0')]
else:
raise TypeError('Unknown array item type')
else:
return u'a'
def _expected_exception(type_):
if isinstance(type_, ARRAY):
return IntegrityError
else:
return DataError
def __init__(self, arg, default=None, **kw):
self.type = postgresql.ARRAY(arg.type)
self.default = default
GenericFunction.__init__(self, arg, **kw)
test_expressions.py 文件源码
项目:deb-python-sqlalchemy-utils
作者: openstack
项目源码
文件源码
阅读 23
收藏 0
点赞 0
评论 0
def test_type(self):
assert isinstance(
sa.func.array_agg(sa.text('u.name')).type,
postgresql.ARRAY
)
test_expressions.py 文件源码
项目:deb-python-sqlalchemy-utils
作者: openstack
项目源码
文件源码
阅读 22
收藏 0
点赞 0
评论 0
def test_array_agg_with_default(self):
Base = sa.ext.declarative.declarative_base()
class Article(Base):
__tablename__ = 'article'
id = sa.Column(sa.Integer, primary_key=True)
assert str(sa.func.array_agg(Article.id, [1]).compile(
dialect=postgresql.dialect()
)) == (
'coalesce(array_agg(article.id), CAST(ARRAY[%(param_1)s]'
' AS INTEGER[]))'
)
def Any(other, arrexpr, operator=operators.eq):
"""A synonym for the :meth:`.ARRAY.Comparator.any` method.
This method is legacy and is here for backwards-compatibility.
.. seealso::
:func:`.expression.any_`
"""
return arrexpr.any(other, operator)
def All(other, arrexpr, operator=operators.eq):
"""A synonym for the :meth:`.ARRAY.Comparator.all` method.
This method is legacy and is here for backwards-compatibility.
.. seealso::
:func:`.expression.all_`
"""
return arrexpr.all(other, operator)
def __init__(self, clauses, **kw):
super(array, self).__init__(*clauses, **kw)
self.type = ARRAY(self.type)
20160224180815_trials_create_table.py 文件源码
项目:collectors
作者: opentrials
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def upgrade():
op.create_table('trials',
sa.Column('uuid', UUID, primary_key=True),
sa.Column('updated', sa.DateTime(timezone=True), nullable=False),
sa.Column('records', ARRAY(sa.Text), nullable=False, unique=True),
sa.Column('nct_id', sa.Text, unique=True),
sa.Column('euctr_id', sa.Text, unique=True),
sa.Column('isrctn_id', sa.Text, unique=True),
sa.Column('scientific_title', sa.Text, unique=True),
)
20160323145124_trials_remove_table.py 文件源码
项目:collectors
作者: opentrials
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def downgrade():
op.create_table('trials',
sa.Column('uuid', UUID, primary_key=True),
sa.Column('updated', sa.DateTime(timezone=True), nullable=False),
sa.Column('records', ARRAY(sa.Text), nullable=False, unique=True),
sa.Column('nct_id', sa.Text, unique=True),
sa.Column('euctr_id', sa.Text, unique=True),
sa.Column('isrctn_id', sa.Text, unique=True),
sa.Column('scientific_title', sa.Text, unique=True),
)
20160301131954_ictrp_create_table.py 文件源码
项目:collectors
作者: opentrials
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def upgrade():
op.create_table('ictrp',
# Meta
sa.Column('meta_uuid', sa.Text),
sa.Column('meta_source', sa.Text),
sa.Column('meta_created', sa.DateTime(timezone=True)),
sa.Column('meta_updated', sa.DateTime(timezone=True)),
# Main
sa.Column('register', sa.Text, primary_key=True),
sa.Column('last_refreshed_on', sa.Date),
sa.Column('main_id', sa.Text, primary_key=True),
sa.Column('date_of_registration', sa.Text),
sa.Column('primary_sponsor', sa.Text),
sa.Column('public_title', sa.Text),
sa.Column('scientific_title', sa.Text),
sa.Column('date_of_first_enrollment', sa.Text),
sa.Column('target_sample_size', sa.Integer),
sa.Column('recruitment_status', sa.Text),
sa.Column('url', sa.Text),
sa.Column('study_type', sa.Text),
sa.Column('study_design', sa.Text),
sa.Column('study_phase', sa.Text),
# Additional
sa.Column('countries_of_recruitment', ARRAY(sa.Text)),
sa.Column('contacts', JSONB),
sa.Column('key_inclusion_exclusion_criteria', sa.Text),
sa.Column('health_conditions_or_problems_studied', ARRAY(sa.Text)),
sa.Column('interventions', ARRAY(sa.Text)),
sa.Column('primary_outcomes', ARRAY(sa.Text)),
sa.Column('secondary_outcomes', ARRAY(sa.Text)),
sa.Column('secondary_ids', ARRAY(sa.Text)),
sa.Column('sources_of_monetary_support', ARRAY(sa.Text)),
sa.Column('secondary_sponsors', ARRAY(sa.Text)),
)
def __init__(self, field=None, **params):
super(Array, self).__init__(**params)
if field is None:
field = Text()
self.__field = field
self.__column_type = ARRAY(field.column_type)
65dec3b9f282_added_feature_and_forest_columns_to_.py 文件源码
项目:research-eGrader
作者: openstax
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('exercises', sa.Column('features', postgresql.ARRAY(sa.Integer()), nullable=True))
op.add_column('exercises', sa.Column('forest_name', sa.String(), nullable=True))
### end Alembic commands ###
fa43b02e45fa_added_vocab_array_field_to_exercise_.py 文件源码
项目:research-eGrader
作者: openstax
项目源码
文件源码
阅读 24
收藏 0
点赞 0
评论 0
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.add_column('exercises', sa.Column('vocab', postgresql.ARRAY(sa.String()), nullable=True))
### end Alembic commands ###
def Any(other, arrexpr, operator=operators.eq):
"""A synonym for the :meth:`.ARRAY.Comparator.any` method.
This method is legacy and is here for backwards-compatibility.
.. seealso::
:func:`.expression.any_`
"""
return arrexpr.any(other, operator)