sqlalchemy.func.lala - python examples

Here are the examples of the python api sqlalchemy.func.lala taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

3 View Complete Implementation : test_insert.py
Copyright MIT License
Author : sqlalchemy
    def test_insert_with_values_func(self):
        table1 = self.tables.mytable

        self.astert_compile(
            insert(table1, values=dict(myid=func.lala())),
            "INSERT INTO mytable (myid) VALUES (lala())",
        )

0 View Complete Implementation : test_functions.py
Copyright MIT License
Author : sqlalchemy
    def test_astorted(self):
        table1 = table("mytable", column("myid", Integer))

        table2 = table("myothertable", column("otherid", Integer))

        # test an expression with a function
        self.astert_compile(
            func.lala(3, 4, literal("five"), table1.c.myid) * table2.c.otherid,
            "lala(:lala_1, :lala_2, :param_1, mytable.myid) * "
            "myothertable.otherid",
        )

        # test it in a SELECT
        self.astert_compile(
            select([func.count(table1.c.myid)]),
            "SELECT count(mytable.myid) AS count_1 FROM mytable",
        )

        # test a "dotted" function name
        self.astert_compile(
            select([func.foo.bar.lala(table1.c.myid)]),
            "SELECT foo.bar.lala(mytable.myid) AS lala_1 FROM mytable",
        )

        # test the bind parameter name with a "dotted" function name is
        # only the name (limits the length of the bind param name)
        self.astert_compile(
            select([func.foo.bar.lala(12)]),
            "SELECT foo.bar.lala(:lala_2) AS lala_1",
        )

        # test a dotted func off the engine itself
        self.astert_compile(func.lala.hoho(7), "lala.hoho(:hoho_1)")

        # test None becomes NULL
        self.astert_compile(
            func.my_func(1, 2, None, 3),
            "my_func(:my_func_1, :my_func_2, NULL, :my_func_3)",
        )

        # test pickling
        self.astert_compile(
            util.pickle.loads(util.pickle.dumps(func.my_func(1, 2, None, 3))),
            "my_func(:my_func_1, :my_func_2, NULL, :my_func_3)",
        )

        # astert func raises AttributeError for __bases__ attribute, since
        # its not a clast fixes pydoc
        try:
            func.__bases__
            astert False
        except AttributeError:
            astert True