示例#1
0
    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)
    def test_functional_index_w_string_cols_combo(self):
        metadata = MetaData()
        x = Table(
            "x",
            metadata,
            Column("q", String(50)),
            Column("p", Integer),
            Column("z", Integer),
        )

        for idx, ddl in [
            (
                Index("y", func.lower(x.c.q), "p", x.c.z),
                "CREATE INDEX y ON x (lower(q), p, z)",
            ),
            (
                Index("y", "p", func.lower(x.c.q), "z"),
                "CREATE INDEX y ON x (p, lower(q), z)",
            ),
            (
                Index("y", "p", "z", func.lower(x.c.q)),
                "CREATE INDEX y ON x (p, z, lower(q))",
            ),
            (
                Index("y", func.foo("foob"), x.c.p, "z"),
                "CREATE INDEX y ON x (foo('foob'), p, z)",
            ),
            (
                Index("y", x.c.p, func.foo("foob"), "z"),
                "CREATE INDEX y ON x (p, foo('foob'), z)",
            ),
            (
                Index("y", func.foo("foob"), "p", "z"),
                "CREATE INDEX y ON x (foo('foob'), p, z)",
            ),
        ]:
            x.append_constraint(idx)
            self.assert_compile(schema.CreateIndex(idx), ddl)
 def test_returning_no_autoinc(self):
     meta = self.metadata
     table = Table(
         "t1",
         meta,
         Column("id", Integer, primary_key=True),
         Column("data", String(50)),
     )
     table.create()
     result = (
         table.insert()
         .values(id=1, data=func.lower("SomeString"))
         .returning(table.c.id, table.c.data)
         .execute()
     )
     eq_(result.fetchall(), [(1, "somestring")])
    def test_returning_insert_functional(self):
        t1 = table("t1", column("c1"), column("c2", String()),
                   column("c3", String()))
        fn = func.lower(t1.c.c2, type_=String())
        stmt = t1.insert().values(c1=1).returning(fn, t1.c.c3)
        compiled = stmt.compile(dialect=oracle.dialect())
        eq_(
            compiled._create_result_map(),
            {
                "c3": ("c3", (t1.c.c3, "c3", "c3"), t1.c.c3.type),
                "lower": ("lower", (fn, "lower", None), fn.type),
            },
        )

        self.assert_compile(
            stmt,
            "INSERT INTO t1 (c1) VALUES (:c1) RETURNING "
            "lower(t1.c2), t1.c3 INTO :ret_0, :ret_1",
        )
示例#5
0
 def column_expression(self, col):
     return func.lower(col)
示例#6
0
 def bind_expression(self, bindvalue):
     return func.lower(bindvalue)
示例#7
0
 class Foo(AbstractFoo):
     __tablename__ = "foo"
     column_prop = column_property(
         func.lower(AbstractFoo.unrelated_data))