예제 #1
0
  public void rollback_transaction_after_exception() {
    using (var db = new session().start_transaction()) {
      db.execute("update users set email = '*****@*****.**' where id = 5");
      throw new Exception("This exception should cause rollback");
      db.commit();
    }
    
    var user = new session()
      .one<user>("where id = 5");

    assert(user.email == "*****@*****.**");
  }
예제 #2
0
  [TestMethod] public void cache() {
    var db = new session();
    var count = db
      .cache("count")
      .one<int>("select count(email) from users");
    
    db.execute("insert into users (email, password) values ('*****@*****.**', 'blood')");

    var new_count = db
      .cache("count")
      .one<int>("select count(email) from users");

    assert(count == new_count);

    var diff = db.one<int>("select count(email) from users");

    assert(diff > count);
  }
예제 #3
0
  public void commit_transaction() {
    using (var db = new session().start_transaction()) {
      db.execute("update users set email = '*****@*****.**' where id = 4");
      db.commit();
    }

    var user = new session()
      .param("@id", 4)
      .one<user>("where id=@id");

    assert(user.email == "*****@*****.**");
  }