def test_compile(self): for dialect in all_dialects(exclude=('sybase', 'access', 'informix', 'maxdb')): bindtemplate = BIND_TEMPLATES[dialect.paramstyle] self.assert_compile(func.current_timestamp(), "CURRENT_TIMESTAMP", dialect=dialect) self.assert_compile(func.localtime(), "LOCALTIME", dialect=dialect) if isinstance(dialect, (firebird.dialect, maxdb.dialect, oracle.dialect)): self.assert_compile(func.nosuchfunction(), "nosuchfunction", dialect=dialect) else: self.assert_compile(func.nosuchfunction(), "nosuchfunction()", dialect=dialect) # test generic function compile class fake_func(GenericFunction): __return_type__ = sqltypes.Integer def __init__(self, arg, **kwargs): GenericFunction.__init__(self, args=[arg], **kwargs) self.assert_compile(fake_func('foo'), "fake_func(%s)" % bindtemplate % { 'name': 'param_1', 'position': 1 }, dialect=dialect)
def test_compile(self): for dialect in all_dialects(exclude=('sybase', 'access', 'informix', 'maxdb')): bindtemplate = BIND_TEMPLATES[dialect.paramstyle] self.assert_compile(func.current_timestamp(), "CURRENT_TIMESTAMP", dialect=dialect) self.assert_compile(func.localtime(), "LOCALTIME", dialect=dialect) if isinstance(dialect, (firebird.dialect, maxdb.dialect, oracle.dialect)): self.assert_compile(func.nosuchfunction(), "nosuchfunction", dialect=dialect) else: self.assert_compile(func.nosuchfunction(), "nosuchfunction()", dialect=dialect) # test generic function compile class fake_func(GenericFunction): __return_type__ = sqltypes.Integer def __init__(self, arg, **kwargs): GenericFunction.__init__(self, args=[arg], **kwargs) self.assert_compile( fake_func('foo'), "fake_func(%s)" % bindtemplate % {'name':'param_1', 'position':1}, dialect=dialect)
from sqlalchemy import * from sqlalchemy.sql import table, column from sqlalchemy import databases, sql, util from sqlalchemy.sql.compiler import BIND_TEMPLATES from sqlalchemy.engine import default from sqlalchemy.test.engines import all_dialects from sqlalchemy import types as sqltypes from sqlalchemy.test import * from sqlalchemy.sql.functions import GenericFunction from sqlalchemy.test.testing import eq_ from decimal import Decimal as _python_Decimal from sqlalchemy.databases import * # FIXME! dialects = [d for d in all_dialects() if d.name not in ('access', 'informix')] class CompileTest(TestBase, AssertsCompiledSQL): def test_compile(self): for dialect in dialects: bindtemplate = BIND_TEMPLATES[dialect.paramstyle] self.assert_compile(func.current_timestamp(), "CURRENT_TIMESTAMP", dialect=dialect) self.assert_compile(func.localtime(), "LOCALTIME", dialect=dialect) if isinstance(dialect, firebird.dialect): self.assert_compile(func.nosuchfunction(), "nosuchfunction", dialect=dialect) else:
from sqlalchemy import * from sqlalchemy.sql import table, column from sqlalchemy import databases, sql, util from sqlalchemy.sql.compiler import BIND_TEMPLATES from sqlalchemy.engine import default from sqlalchemy.test.engines import all_dialects from sqlalchemy import types as sqltypes from sqlalchemy.test import * from sqlalchemy.sql.functions import GenericFunction from sqlalchemy.test.testing import eq_ from decimal import Decimal as _python_Decimal from sqlalchemy.databases import * # FIXME! dialects = [d for d in all_dialects() if d.name not in ('access', 'informix')] class CompileTest(TestBase, AssertsCompiledSQL): def test_compile(self): for dialect in dialects: bindtemplate = BIND_TEMPLATES[dialect.paramstyle] self.assert_compile(func.current_timestamp(), "CURRENT_TIMESTAMP", dialect=dialect) self.assert_compile(func.localtime(), "LOCALTIME", dialect=dialect) if isinstance(dialect, firebird.dialect): self.assert_compile(func.nosuchfunction(), "nosuchfunction", dialect=dialect) else: self.assert_compile(func.nosuchfunction(), "nosuchfunction()", dialect=dialect) # test generic function compile class fake_func(GenericFunction):