コード例 #1
0
        public void test_column_origin()
        {
            using (sqlite3 db = ugly.open(":memory:"))
            {
                db.exec("CREATE TABLE foo (x int, v int, t text, d real, b blob, q blob);");
                byte[] blob = db.query_scalar <byte[]>("SELECT randomblob(5);");
                db.exec("INSERT INTO foo (x,v,t,d,b,q) VALUES (?,?,?,?,?,?)", 32, 44, "hello", 3.14, blob, null);
#if not
                // maybe we should just let this fail so we can
                // see the differences between running against the built-in
                // sqlite vs a recent version?
                if (1 == raw.sqlite3_compileoption_used("ENABLE_COLUMN_METADATA"))
#endif
                {
                    using (sqlite3_stmt stmt = db.prepare("SELECT x AS mario FROM foo;"))
                    {
                        stmt.step();

                        Assert.IsTrue(stmt.stmt_readonly() != 0);

                        Assert.AreEqual(stmt.column_database_name(0), "main");
                        Assert.AreEqual(stmt.column_table_name(0), "foo");
                        Assert.AreEqual(stmt.column_origin_name(0), "x");
                        Assert.AreEqual(stmt.column_name(0), "mario");
                        Assert.AreEqual(stmt.column_decltype(0), "int");
                    }
                }
            }
        }
コード例 #2
0
        public void test_bind_parameter_index()
        {
            using (sqlite3 db = ugly.open(":memory:"))
            {
                db.exec("CREATE TABLE foo (x int, v int, t text, d real, b blob, q blob);");
                using (sqlite3_stmt stmt = db.prepare("INSERT INTO foo (x,v,t,d,b,q) VALUES (:x,:v,:t,:d,:b,:q)"))
                {
                    Assert.IsTrue(stmt.stmt_readonly() == 0);

                    Assert.AreEqual(stmt.bind_parameter_count(), 6);

                    Assert.AreEqual(stmt.bind_parameter_index(":m"), 0);

                    Assert.AreEqual(stmt.bind_parameter_index(":x"), 1);
                    Assert.AreEqual(stmt.bind_parameter_index(":v"), 2);
                    Assert.AreEqual(stmt.bind_parameter_index(":t"), 3);
                    Assert.AreEqual(stmt.bind_parameter_index(":d"), 4);
                    Assert.AreEqual(stmt.bind_parameter_index(":b"), 5);
                    Assert.AreEqual(stmt.bind_parameter_index(":q"), 6);

                    Assert.AreEqual(stmt.bind_parameter_name(1), ":x");
                    Assert.AreEqual(stmt.bind_parameter_name(2), ":v");
                    Assert.AreEqual(stmt.bind_parameter_name(3), ":t");
                    Assert.AreEqual(stmt.bind_parameter_name(4), ":d");
                    Assert.AreEqual(stmt.bind_parameter_name(5), ":b");
                    Assert.AreEqual(stmt.bind_parameter_name(6), ":q");
                }
            }
        }