Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DBTransaction For DataBase #107

Merged
merged 3 commits into from
Dec 3, 2023
Merged

Support DBTransaction For DataBase #107

merged 3 commits into from
Dec 3, 2023

Conversation

KKould
Copy link
Member

@KKould KKould commented Dec 1, 2023

What problem does this PR solve?

#[tokio::main]
async fn main() -> Result<(), DatabaseError> {
    let database = Database::with_kipdb("./transaction").await?;
    let mut tx_1 = database.new_transaction().await?;

    let _ = tx_1
        .run("create table if not exists t1 (c1 int primary key, c2 int)")
        .await?;
    let _ = tx_1
        .run("insert into t1 values(0, 0), (1, 1)")
        .await?;

    assert!(database.run("select * from t1").await.is_err());

    tx_1.commit().await?;

    assert!(database.run("select * from t1").await.is_ok());

    let _ = database.run("drop table t1").await?;

    Ok(())
}

What is changed and how it works?

Code changes

  • Has Rust code change
  • Has CI related scripts change

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Note for reviewer

@KKould KKould self-assigned this Dec 1, 2023
@KKould KKould added the enhancement New feature or request label Dec 3, 2023
@KKould KKould merged commit bc211d7 into KipData:main Dec 3, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant