Here are the examples of the python api sqlalchemy.ARRAY taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
10 Examples
3
Source : queries.py
with MIT License
from bihealth
with MIT License
from bihealth
def extend_conditions(self, _query_parts):
# Matching variant effect and whether there has to be an overlap.
effects = cast(self.kwargs["effects"], ARRAY(VARCHAR()))
result = self._effect_field().overlap(effects)
if not self.kwargs["require_transcript_overlap"]:
result = or_(result, self._effect_field().is_(None))
yield result
# Whether to include coding/non-coding transcripts.
if not self.kwargs["transcripts_coding"]:
yield self._transcript_coding_field() == False # equality from SQL Alchemy
if not self.kwargs["transcripts_noncoding"]:
yield self._transcript_coding_field() == True # equality from SQL Alchemy
def _effect_field(self):
3
Source : test_functions.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_array_agg_array_datatype(self):
expr = func.array_agg(column("data", ARRAY(Integer)))
is_(expr.type._type_affinity, ARRAY)
is_(expr.type.item_type._type_affinity, Integer)
def test_array_agg_array_literal_implicit_type(self):
3
Source : test_functions.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_array_agg_array_literal_explicit_type(self):
from sqlalchemy.dialects.postgresql import array
expr = array([column("data", Integer), column("d2", Integer)])
agg_expr = func.array_agg(expr, type_=ARRAY(Integer))
is_(agg_expr.type._type_affinity, ARRAY)
is_(agg_expr.type.item_type._type_affinity, Integer)
self.assert_compile(
agg_expr, "array_agg(ARRAY[data, d2])", dialect="postgresql"
)
def test_mode(self):
3
Source : test_metadata.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_before_parent_attach_array_enclosing_schematype(self):
# test for [ticket:4141] which is the same idea as [ticket:3832]
# for ARRAY
typ = ARRAY(String)
self._test_before_parent_attach(typ)
def test_before_parent_attach_typedec_of_schematype(self):
3
Source : test_types.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_array_index_map_dimensions(self):
col = column("x", ARRAY(Integer, dimensions=3))
is_(col[5].type._type_affinity, ARRAY)
eq_(col[5].type.dimensions, 2)
is_(col[5][6].type._type_affinity, ARRAY)
eq_(col[5][6].type.dimensions, 1)
is_(col[5][6][7].type._type_affinity, Integer)
def test_array_getitem_single_type(self):
3
Source : test_types.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_array_getitem_single_type(self):
m = MetaData()
arrtable = Table(
"arrtable",
m,
Column("intarr", ARRAY(Integer)),
Column("strarr", ARRAY(String)),
)
is_(arrtable.c.intarr[1].type._type_affinity, Integer)
is_(arrtable.c.strarr[1].type._type_affinity, String)
def test_array_getitem_slice_type(self):
3
Source : test_types.py
with Apache License 2.0
from gethue
with Apache License 2.0
from gethue
def test_array_getitem_slice_type(self):
m = MetaData()
arrtable = Table(
"arrtable",
m,
Column("intarr", ARRAY(Integer)),
Column("strarr", ARRAY(String)),
)
is_(arrtable.c.intarr[1:3].type._type_affinity, ARRAY)
is_(arrtable.c.strarr[1:3].type._type_affinity, ARRAY)
def test_array_getitem_slice_type_dialect_level(self):
3
Source : upgrade.py
with MIT License
from OneGov
with MIT License
from OneGov
def add_attendee_permissions_col(context):
if not context.has_column('fsi_attendees', 'permissions'):
context.add_column_with_defaults(
'fsi_attendees',
Column('permissions', ARRAY(Text), default=list),
default=lambda x: []
)
@upgrade_task('Make Notification.text nullable')
0
Source : test_types.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def test_type_specific_slice_update(
self, type_specific_fixture, connection, type_, gen
):
table = type_specific_fixture(gen)
new_gen = gen(3)
if not table.c.bar.type._variant_mapping:
# this is not likely to occur to users but we need to just
# exercise this as far as we can
expr = type_coerce(table.c.bar, ARRAY(type_))[1:3]
else:
expr = table.c.bar[1:3]
connection.execute(
table.update().where(table.c.id == 2).values({expr: new_gen[1:4]})
)
rows = connection.execute(
select(table.c.bar).order_by(table.c.id)
).all()
sliced_gen = gen(2)
sliced_gen[0:3] = new_gen[1:4]
eq_(rows, [(gen(1),), (sliced_gen,)])
@_type_combinations(exclude_json=True, exclude_empty_lists=True)
0
Source : test_update.py
with MIT License
from sqlalchemy
with MIT License
from sqlalchemy
def random_update_order_parameters():
from sqlalchemy import ARRAY
t = table(
"foo",
column("data1", ARRAY(Integer)),
column("data2", ARRAY(Integer)),
column("data3", ARRAY(Integer)),
column("data4", ARRAY(Integer)),
)
idx_to_value = [
(t.c.data1, 5, 7),
(t.c.data2, 10, 18),
(t.c.data3, 8, 4),
(t.c.data4, 12, 14),
]
def combinations():
while True:
random.shuffle(idx_to_value)
yield list(idx_to_value)
return testing.combinations(
*[
(t, combination)
for i, combination in zip(range(10), combinations())
],
argnames="t, idx_to_value",
)
@random_update_order_parameters()