Here are the examples of the python api sqlalchemy.testing.fails_on taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
25 Examples
3
Example 1
Project: sqlalchemy Source File: test_types.py
@testing.fails_on("mysql+oursql", "TODO: probable OurSQL bug")
@testing.provide_metadata
def test_time_roundtrip(self):
t = Table('mysql_time', self.metadata,
Column('t1', mysql.TIME())
)
t.create()
t.insert().values(t1=datetime.time(8, 37, 35)).execute()
eq_(select([t.c.t1]).scalar(), datetime.time(8, 37, 35))
3
Example 2
@testing.fails_on('+zxjdbc',
"Can't infer the SQL type to use for an instance "
"of org.python.core.PyObjectDerived.")
def test_extract(self):
fivedaysago = datetime.datetime.now() \
- datetime.timedelta(days=5)
for field, exp in ('year', fivedaysago.year), \
('month', fivedaysago.month), ('day', fivedaysago.day):
r = testing.db.execute(
select([
extract(field, func.now() + datetime.timedelta(days=-5))])
).scalar()
eq_(r, exp)
3
Example 3
Project: sqlalchemy Source File: test_dialect.py
@testing.fails_on('+zxjdbc', 'psycopg2/pg8000 specific assertion')
@testing.requires.psycopg2_or_pg8000_compatibility
def test_numeric_raise(self):
stmt = text(
"select cast('hi' as char) as hi", typemap={'hi': Numeric})
assert_raises(exc.InvalidRequestError, testing.db.execute, stmt)
3
Example 4
Project: sqlalchemy Source File: test_query.py
@testing.fails_on('postgresql+pg8000', 'uses positional')
@testing.fails_on('postgresql+zxjdbc', 'uses qmark')
def test_expression_pyformat(self):
self.assert_compile(matchtable.c.title.match('somstr'),
'matchtable.title @@ to_tsquery(%(title_1)s'
')')
3
Example 5
Project: sqlalchemy Source File: test_query.py
@testing.fails_on('postgresql+psycopg2', 'uses pyformat')
@testing.fails_on('postgresql+pypostgresql', 'uses pyformat')
@testing.fails_on('postgresql+pygresql', 'uses pyformat')
@testing.fails_on('postgresql+zxjdbc', 'uses qmark')
@testing.fails_on('postgresql+psycopg2cffi', 'uses pyformat')
def test_expression_positional(self):
self.assert_compile(matchtable.c.title.match('somstr'),
'matchtable.title @@ to_tsquery(%s)')
3
Example 6
Project: sqlalchemy Source File: test_composites.py
@testing.fails_on('mssql', 'Cannot update identity columns.')
def test_pk_mutation(self):
Graph, Version = self.classes.Graph, self.classes.Version
sess = self._fixture()
g = sess.query(Graph).first()
g.version = Version(2, 1)
sess.commit()
g2 = sess.query(Graph).get(Version(2, 1))
eq_(g.version, g2.version)
3
Example 7
@testing.fails_on('firebird', 'FIXME: unknown')
@testing.fails_on('mssql', 'AVG produces an average as the original column type on mssql.')
def test_aggregate_2(self):
foo = self.tables.foo
query = create_session().query(func.avg(foo.c.bar))
avg = query.filter(foo.c.bar < 30).one()[0]
eq_(float(round(avg, 1)), 14.5)
3
Example 8
Project: sqlalchemy Source File: test_generative.py
@testing.fails_on('mssql', 'AVG produces an average as the original column type on mssql.')
def test_aggregate_3(self):
foo, Foo = self.tables.foo, self.classes.Foo
query = create_session().query(Foo)
avg_f = next(query.filter(foo.c.bar<30).values(sa.func.avg(foo.c.bar)))[0]
assert float(round(avg_f, 1)) == 14.5
avg_o = next(query.filter(foo.c.bar<30).values(sa.func.avg(foo.c.bar)))[0]
assert float(round(avg_o, 1)) == 14.5
3
Example 9
Project: sqlalchemy Source File: test_insert_exec.py
@testing.fails_on(
'mssql', "lowercase table doesn't support identity insert disable")
def test_direct_params(self):
t = self._fixture()
self._test(
t.insert().values(id=1, data='data', x=5),
(1, 'data', 5),
inserted_primary_key=[]
)
3
Example 10
Project: sqlalchemy Source File: test_insert_exec.py
@testing.fails_on(
'mssql', "lowercase table doesn't support identity insert disable")
@testing.requires.returning
def test_direct_params_returning(self):
t = self._fixture()
self._test(
t.insert().values(id=1, data='data', x=5).returning(t.c.id, t.c.x),
(1, 'data', 5),
returning=(1, 5)
)
3
Example 11
Project: sqlalchemy Source File: test_query.py
@testing.fails_on('firebird', "doesn't like ORDER BY with UNIONs")
def test_union_ordered(self):
(s1, s2) = (
select([t1.c.col3.label('col3'), t1.c.col4.label('col4')],
t1.c.col2.in_(["t1col2r1", "t1col2r2"])),
select([t2.c.col3.label('col3'), t2.c.col4.label('col4')],
t2.c.col2.in_(["t2col2r2", "t2col2r3"]))
)
u = union(s1, s2, order_by=['col3', 'col4'])
wanted = [('aaa', 'aaa'), ('bbb', 'bbb'), ('bbb', 'ccc'),
('ccc', 'aaa')]
eq_(u.execute().fetchall(), wanted)
3
Example 12
Project: sqlalchemy Source File: test_query.py
@testing.fails_on('firebird', "doesn't like ORDER BY with UNIONs")
@testing.requires.subqueries
def test_union_ordered_alias(self):
(s1, s2) = (
select([t1.c.col3.label('col3'), t1.c.col4.label('col4')],
t1.c.col2.in_(["t1col2r1", "t1col2r2"])),
select([t2.c.col3.label('col3'), t2.c.col4.label('col4')],
t2.c.col2.in_(["t2col2r2", "t2col2r3"]))
)
u = union(s1, s2, order_by=['col3', 'col4'])
wanted = [('aaa', 'aaa'), ('bbb', 'bbb'), ('bbb', 'ccc'),
('ccc', 'aaa')]
eq_(u.alias('bar').select().execute().fetchall(), wanted)
3
Example 13
Project: sqlalchemy Source File: test_query.py
@testing.fails_on('sqlite', "Can't handle this style of nesting")
@testing.requires.except_
def test_except_style3(self):
# aaa, bbb, ccc - (aaa, bbb, ccc - (ccc)) = ccc
e = except_(
select([t1.c.col3]), # aaa, bbb, ccc
except_(
select([t2.c.col3]), # aaa, bbb, ccc
select([t3.c.col3], t3.c.col3 == 'ccc'), # ccc
)
)
eq_(e.execute().fetchall(), [('ccc',)])
eq_(e.alias('foo').select().execute().fetchall(), [('ccc',)])
3
Example 14
Project: sqlalchemy Source File: test_returning.py
@testing.fails_on('firebird', "fb can't handle returning x AS y")
def test_labeling(self):
result = table.insert().values(persons=6).\
returning(table.c.persons.label('lala')).execute()
row = result.first()
assert row['lala'] == 6
3
Example 15
Project: sqlalchemy Source File: test_returning.py
@testing.fails_on(
'firebird',
"fb/kintersbasdb can't handle the bind params")
@testing.fails_on('oracle+zxjdbc', "JDBC driver bug")
def test_anon_expressions(self):
result = table.insert().values(goofy="someOTHERgoofy").\
returning(func.lower(table.c.goofy, type_=GoofyType)).execute()
row = result.first()
eq_(row[0], "foosomeothergoofyBAR")
result = table.insert().values(persons=12).\
returning(table.c.persons + 18).execute()
row = result.first()
eq_(row[0], 30)
3
Example 16
Project: sqlalchemy Source File: test_returning.py
@testing.fails_on("oracle+cx_oracle", "seems like a cx_oracle bug")
def test_insert_non_default_plus_default(self):
t1 = self.tables.t1
result = testing.db.execute(
t1.insert().values(upddef=1).return_defaults(
t1.c.data, t1.c.insdef)
)
eq_(
dict(result.returned_defaults),
{"id": 1, "data": None, "insdef": 0}
)
3
Example 17
Project: sqlalchemy Source File: test_returning.py
@testing.fails_on("oracle+cx_oracle", "seems like a cx_oracle bug")
def test_update_non_default_plus_default(self):
t1 = self.tables.t1
testing.db.execute(
t1.insert().values(upddef=1)
)
result = testing.db.execute(
t1.update().
values(insdef=2).return_defaults(
t1.c.data, t1.c.upddef))
eq_(
dict(result.returned_defaults),
{"data": None, 'upddef': 1}
)
3
Example 18
@testing.fails_on("oracle+cx_oracle", "seems like a cx_oracle bug")
def test_insert_all(self):
t1 = self.tables.t1
result = testing.db.execute(
t1.insert().values(upddef=1).return_defaults()
)
eq_(
dict(result.returned_defaults),
{"id": 1, "data": None, "insdef": 0}
)
3
Example 19
@testing.fails_on("oracle+cx_oracle", "seems like a cx_oracle bug")
def test_update_all(self):
t1 = self.tables.t1
testing.db.execute(
t1.insert().values(upddef=1)
)
result = testing.db.execute(
t1.update().
values(insdef=2).return_defaults()
)
eq_(
dict(result.returned_defaults),
{'upddef': 1}
)
0
Example 20
Project: sqlalchemy Source File: test_dialect.py
@testing.fails_on('+zxjdbc',
'The JDBC driver handles the version parsing')
def test_version_parsing(self):
def mock_conn(res):
return Mock(
execute=Mock(return_value=Mock(scalar=Mock(return_value=res))))
for string, version in [
(
'PostgreSQL 8.3.8 on i686-redhat-linux-gnu, compiled by '
'GCC gcc (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33)',
(8, 3, 8)),
(
'PostgreSQL 8.5devel on x86_64-unknown-linux-gnu, '
'compiled by GCC gcc (GCC) 4.4.2, 64-bit', (8, 5)),
(
'EnterpriseDB 9.1.2.2 on x86_64-unknown-linux-gnu, '
'compiled by gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-50), '
'64-bit', (9, 1, 2)),
(
'[PostgreSQL 9.2.4 ] VMware vFabric Postgres 9.2.4.0 '
'release build 1080137', (9, 2, 4))]:
eq_(testing.db.dialect._get_server_version_info(mock_conn(string)),
version)
0
Example 21
Project: sqlalchemy Source File: test_update_delete.py
@testing.fails_on('mysql', 'FIXME: unknown')
def test_delete_invalid_evaluation(self):
User = self.classes.User
sess = Session()
john, jack, jill, jane = sess.query(User).order_by(User.id).all()
assert_raises(exc.InvalidRequestError,
sess.query(User).
filter(
User.name == select([func.max(User.name)])).delete,
synchronize_session='evaluate'
)
sess.query(User).filter(User.name == select([func.max(User.name)])).\
delete(synchronize_session='fetch')
assert john not in sess
eq_(sess.query(User).order_by(User.id).all(), [jack, jill, jane])
0
Example 22
Project: sqlalchemy Source File: test_case_statement.py
@testing.fails_on('firebird', 'FIXME: unknown')
@testing.requires.subqueries
def test_case(self):
inner = select(
[
case(
[
[info_table.c.pk < 3, 'lessthan3'],
[
and_(info_table.c.pk >= 3, info_table.c.pk < 7),
'gt3']]).label('x'),
info_table.c.pk, info_table.c.info], from_obj=[info_table])
inner_result = inner.execute().fetchall()
# Outputs:
# lessthan3 1 pk_1_data
# lessthan3 2 pk_2_data
# gt3 3 pk_3_data
# gt3 4 pk_4_data
# gt3 5 pk_5_data
# gt3 6 pk_6_data
assert inner_result == [
('lessthan3', 1, 'pk_1_data'),
('lessthan3', 2, 'pk_2_data'),
('gt3', 3, 'pk_3_data'),
('gt3', 4, 'pk_4_data'),
('gt3', 5, 'pk_5_data'),
('gt3', 6, 'pk_6_data')
]
outer = select([inner.alias('q_inner')])
outer_result = outer.execute().fetchall()
assert outer_result == [
('lessthan3', 1, 'pk_1_data'),
('lessthan3', 2, 'pk_2_data'),
('gt3', 3, 'pk_3_data'),
('gt3', 4, 'pk_4_data'),
('gt3', 5, 'pk_5_data'),
('gt3', 6, 'pk_6_data')
]
w_else = select(
[
case(
[
[info_table.c.pk < 3, cast(3, Integer)],
[
and_(
info_table.c.pk >= 3, info_table.c.pk < 6),
6]],
else_=0).label('x'),
info_table.c.pk, info_table.c.info],
from_obj=[info_table])
else_result = w_else.execute().fetchall()
assert else_result == [
(3, 1, 'pk_1_data'),
(3, 2, 'pk_2_data'),
(6, 3, 'pk_3_data'),
(6, 4, 'pk_4_data'),
(6, 5, 'pk_5_data'),
(0, 6, 'pk_6_data')
]
0
Example 23
Project: sqlalchemy Source File: test_case_statement.py
@testing.fails_on('firebird', 'FIXME: unknown')
def testcase_with_dict(self):
query = select(
[
case(
{
info_table.c.pk < 3: 'lessthan3',
info_table.c.pk >= 3: 'gt3',
}, else_='other'),
info_table.c.pk, info_table.c.info
],
from_obj=[info_table])
assert query.execute().fetchall() == [
('lessthan3', 1, 'pk_1_data'),
('lessthan3', 2, 'pk_2_data'),
('gt3', 3, 'pk_3_data'),
('gt3', 4, 'pk_4_data'),
('gt3', 5, 'pk_5_data'),
('gt3', 6, 'pk_6_data')
]
simple_query = select(
[
case(
{1: 'one', 2: 'two', },
value=info_table.c.pk, else_='other'),
info_table.c.pk
],
whereclause=info_table.c.pk < 4,
from_obj=[info_table])
assert simple_query.execute().fetchall() == [
('one', 1),
('two', 2),
('other', 3),
]
0
Example 24
Project: sqlalchemy Source File: test_insert_exec.py
@testing.fails_on(
'sqlite', "sqlite autoincremnt doesn't work with composite pks")
@testing.provide_metadata
def test_misordered_lastrow(self):
metadata = self.metadata
related = Table(
'related', metadata,
Column('id', Integer, primary_key=True),
mysql_engine='MyISAM'
)
t6 = Table(
"t6", metadata,
Column(
'manual_id', Integer, ForeignKey('related.id'),
primary_key=True),
Column(
'auto_id', Integer, primary_key=True,
test_needs_autoincrement=True),
mysql_engine='MyISAM'
)
metadata.create_all()
r = related.insert().values(id=12).execute()
id_ = r.inserted_primary_key[0]
eq_(id_, 12)
r = t6.insert().values(manual_id=id_).execute()
eq_(r.inserted_primary_key, [12, 1])
0
Example 25
@testing.fails_on(
'firebird', "kinterbasdb doesn't send full type information")
def test_order_by_label(self):
"""test that a label within an ORDER BY works on each backend.
This test should be modified to support [ticket:1068] when that ticket
is implemented. For now, you need to put the actual string in the
ORDER BY.
"""
users.insert().execute(
{'user_id': 7, 'user_name': 'jack'},
{'user_id': 8, 'user_name': 'ed'},
{'user_id': 9, 'user_name': 'fred'},
)
concat = ("test: " + users.c.user_name).label('thedata')
eq_(
select([concat]).order_by("thedata").execute().fetchall(),
[("test: ed",), ("test: fred",), ("test: jack",)]
)
eq_(
select([concat]).order_by("thedata").execute().fetchall(),
[("test: ed",), ("test: fred",), ("test: jack",)]
)
concat = ("test: " + users.c.user_name).label('thedata')
eq_(
select([concat]).order_by(desc('thedata')).execute().fetchall(),
[("test: jack",), ("test: fred",), ("test: ed",)]
)