Python sqlalchemy.sql.functions.GenericFunction.__init__() Examples
The following are 30
code examples of sqlalchemy.sql.functions.GenericFunction.__init__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sqlalchemy.sql.functions.GenericFunction
, or try the search function
.
Example #1
Source File: functions.py From sqlalchemy with MIT License | 6 votes |
def __init__(cls, clsname, bases, clsdict): if annotation.Annotated not in cls.__mro__: cls.name = name = clsdict.get("name", clsname) cls.identifier = identifier = clsdict.get("identifier", name) package = clsdict.pop("package", "_default") # legacy if "__return_type__" in clsdict: cls.type = clsdict["__return_type__"] # Check _register attribute status cls._register = getattr(cls, "_register", True) # Register the function if required if cls._register: register_function(identifier, cls, package) else: # Set _register to True to register child classes by default cls._register = True super(_GenericMeta, cls).__init__(clsname, bases, clsdict)
Example #2
Source File: functions.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, arg, **kwargs): GenericFunction.__init__(self, arg, **kwargs)
Example #3
Source File: functions.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): args = [_literal_as_binds(c) for c in args] kwargs.setdefault('type_', _type_from_args(args)) kwargs['_parsed_args'] = args GenericFunction.__init__(self, *args, **kwargs)
Example #4
Source File: functions.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, *clauses, **kwargs): """Construct a :class:`.FunctionElement`. """ args = [_literal_as_binds(c, self.name) for c in clauses] self.clause_expr = ClauseList( operator=operators.comma_op, group_contents=True, *args).\ self_group()
Example #5
Source File: functions.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, expression=None, **kwargs): if expression is None: expression = literal_column('*') GenericFunction.__init__(self, expression, **kwargs)
Example #6
Source File: functions.py From android_universal with MIT License | 5 votes |
def __init__(self, *clauses, **kwargs): """Construct a :class:`.FunctionElement`. """ args = [_literal_as_binds(c, self.name) for c in clauses] self.clause_expr = ClauseList( operator=operators.comma_op, group_contents=True, *args).\ self_group()
Example #7
Source File: functions.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, arg, **kwargs): GenericFunction.__init__(self, arg, **kwargs)
Example #8
Source File: functions.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, *args, **kwargs): parsed_args = kwargs.pop('_parsed_args', None) if parsed_args is None: parsed_args = [_literal_as_binds(c) for c in args] self.packagenames = [] self._bind = kwargs.get('bind', None) self.clause_expr = ClauseList( operator=operators.comma_op, group_contents=True, *parsed_args).self_group() self.type = sqltypes.to_instance( kwargs.pop("type_", None) or getattr(self, 'type', None))
Example #9
Source File: functions.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(cls, clsname, bases, clsdict): if annotation.Annotated not in cls.__mro__: cls.name = name = clsdict.get('name', clsname) cls.identifier = identifier = clsdict.get('identifier', name) package = clsdict.pop('package', '_default') # legacy if '__return_type__' in clsdict: cls.type = clsdict['__return_type__'] register_function(identifier, cls, package) super(_GenericMeta, cls).__init__(clsname, bases, clsdict)
Example #10
Source File: functions.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, name, *clauses, **kw): """Construct a :class:`.Function`. The :data:`.func` construct is normally used to construct new :class:`.Function` instances. """ self.packagenames = kw.pop('packagenames', None) or [] self.name = name self._bind = kw.get('bind', None) self.type = sqltypes.to_instance(kw.get('type_', None)) FunctionElement.__init__(self, *clauses, **kw)
Example #11
Source File: functions.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, **opts): self.__names = [] self.opts = opts
Example #12
Source File: functions.py From moviegrabber with GNU General Public License v3.0 | 5 votes |
def __init__(self, **kwargs): GenericFunction.__init__(self, **kwargs)
Example #13
Source File: test_functions.py From sqlalchemy with MIT License | 5 votes |
def test_register_function(self): # test generic function registering class registered_func(GenericFunction): _register = True def __init__(self, *args, **kwargs): GenericFunction.__init__(self, *args, **kwargs) class registered_func_child(registered_func): type = sqltypes.Integer assert "registered_func" in functions._registry["_default"] assert isinstance(func.registered_func_child().type, Integer) class not_registered_func(GenericFunction): _register = False def __init__(self, *args, **kwargs): GenericFunction.__init__(self, *args, **kwargs) class not_registered_func_child(not_registered_func): type = sqltypes.Integer assert "not_registered_func" not in functions._registry["_default"] assert isinstance(func.not_registered_func_child().type, Integer)
Example #14
Source File: test_functions.py From sqlalchemy with MIT License | 5 votes |
def test_custom_name(self): class MyFunction(GenericFunction): name = "my_func" def __init__(self, *args): args = args + (3,) super(MyFunction, self).__init__(*args) self.assert_compile( func.my_func(1, 2), "my_func(:my_func_1, :my_func_2, :my_func_3)" )
Example #15
Source File: test_functions.py From sqlalchemy with MIT License | 5 votes |
def test_compile(self): for dialect in all_dialects(exclude=("sybase",)): bindtemplate = BIND_TEMPLATES[dialect.paramstyle] self.assert_compile( func.current_timestamp(), "CURRENT_TIMESTAMP", dialect=dialect ) self.assert_compile(func.localtime(), "LOCALTIME", dialect=dialect) if dialect.name in ("firebird",): 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, arg, **kwargs) self.assert_compile( fake_func("foo"), "fake_func(%s)" % bindtemplate % {"name": "fake_func_1", "position": 1}, dialect=dialect, ) functions._registry["_default"].pop("fake_func")
Example #16
Source File: functions.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, expression=None, **kwargs): if expression is None: expression = literal_column("*") super(count, self).__init__(expression, **kwargs)
Example #17
Source File: functions.py From jarvis with GNU General Public License v2.0 | 5 votes |
def __init__(self, *clauses, **kwargs): """Construct a :class:`.FunctionElement`. """ args = [_literal_as_binds(c, self.name) for c in clauses] self.clause_expr = ClauseList( operator=operators.comma_op, group_contents=True, *args).\ self_group()
Example #18
Source File: functions.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, *args, **kwargs): args = [ coercions.expect( roles.ExpressionElementRole, c, name=self.name, apply_propagate_attrs=self, ) for c in args ] kwargs.setdefault("type_", _type_from_args(args)) kwargs["_parsed_args"] = args super(ReturnTypeFromArgs, self).__init__(*args, **kwargs)
Example #19
Source File: functions.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, *args, **kwargs): GenericFunction.__init__(self, *args, **kwargs)
Example #20
Source File: functions.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, seq, **kw): assert isinstance( seq, schema.Sequence ), "next_value() accepts a Sequence object as input." self._bind = kw.get("bind", None) self.sequence = seq
Example #21
Source File: functions.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, name, *clauses, **kw): """Construct a :class:`.Function`. The :data:`.func` construct is normally used to construct new :class:`.Function` instances. """ self.packagenames = kw.pop("packagenames", None) or () self.name = name self._bind = kw.get("bind", None) self.type = sqltypes.to_instance(kw.get("type_", None)) FunctionElement.__init__(self, *clauses, **kw)
Example #22
Source File: functions.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, **opts): self.__names = [] self.opts = opts
Example #23
Source File: functions.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, fn, left_index, right_index): self.sql_function = fn self.left_index = left_index self.right_index = right_index self.operator = operators.function_as_comparison_op self.type = sqltypes.BOOLEANTYPE self.negate = None self._is_implicitly_boolean = True self.modifiers = {}
Example #24
Source File: functions.py From sqlalchemy with MIT License | 5 votes |
def __init__(self, *clauses, **kwargs): r"""Construct a :class:`.FunctionElement`. :param \*clauses: list of column expressions that form the arguments of the SQL function call. :param \**kwargs: additional kwargs are typically consumed by subclasses. .. seealso:: :data:`.func` :class:`.Function` """ args = [ coercions.expect( roles.ExpressionElementRole, c, name=getattr(self, "name", None), apply_propagate_attrs=self, ) for c in clauses ] self._has_args = self._has_args or bool(args) self.clause_expr = ClauseList( operator=operators.comma_op, group_contents=True, *args ).self_group()
Example #25
Source File: functions.py From stdm with GNU General Public License v2.0 | 5 votes |
def __init__(self, expression=None, **kwargs): if expression is None: expression = literal_column('*') GenericFunction.__init__(self, expression, **kwargs)
Example #26
Source File: functions.py From stdm with GNU General Public License v2.0 | 5 votes |
def __init__(self, arg, **kwargs): GenericFunction.__init__(self, arg, **kwargs)
Example #27
Source File: functions.py From stdm with GNU General Public License v2.0 | 5 votes |
def __init__(self, *args, **kwargs): args = [_literal_as_binds(c) for c in args] kwargs.setdefault('type_', _type_from_args(args)) kwargs['_parsed_args'] = args GenericFunction.__init__(self, *args, **kwargs)
Example #28
Source File: functions.py From stdm with GNU General Public License v2.0 | 5 votes |
def __init__(self, **kwargs): GenericFunction.__init__(self, **kwargs)
Example #29
Source File: functions.py From stdm with GNU General Public License v2.0 | 5 votes |
def __init__(self, *args, **kwargs): parsed_args = kwargs.pop('_parsed_args', None) if parsed_args is None: parsed_args = [_literal_as_binds(c) for c in args] self.packagenames = [] self._bind = kwargs.get('bind', None) self.clause_expr = ClauseList( operator=operators.comma_op, group_contents=True, *parsed_args).self_group() self.type = sqltypes.to_instance( kwargs.pop("type_", None) or getattr(self, 'type', None))
Example #30
Source File: functions.py From stdm with GNU General Public License v2.0 | 5 votes |
def __init__(cls, clsname, bases, clsdict): if annotation.Annotated not in cls.__mro__: cls.name = name = clsdict.get('name', clsname) cls.identifier = identifier = clsdict.get('identifier', name) package = clsdict.pop('package', '_default') # legacy if '__return_type__' in clsdict: cls.type = clsdict['__return_type__'] register_function(identifier, cls, package) super(_GenericMeta, cls).__init__(clsname, bases, clsdict)