ronantakizawa/codereview-bench huggingface dataset:
Repository: diesel-rs/diesel
File: diesel/src/query_builder/upsert/on_conflict_clause.rs (Rust)

Code before:
use super::on_conflict_actions::*;
use super::on_conflict_target::*;
use crate::backend::sql_dialect;
use crate::backend::Backend;
use crate::insertable::*;
use crate::query_builder::where_clause::NoWhereClause;
use crate::query_builder::*;
use crate::result::QueryResult;

#[doc(hidden)]
#[derive(Debug, Clone, Copy)]
pub struct OnConflictValues<Values, Target, Action, WhereClause> {
    values: Values,
    target: Target,
    action: Action,
    /// Allow to apply filters on ON CONFLICT ... DO UPDATE ... WHERE ...
    where_clause: WhereClause,
}

impl<Values, Target, Action, WhereClause> QueryId
    for OnConflictValues<Values, Target, Action, WhereClause>
{
    type QueryId = ();

    const HAS_STATIC_QUERY_ID: bool = false;
}

impl<Values> OnConflictValues<Values, NoConflictTarget, DoNothing, NoWhereClause> {
    pub(crate) fn do_nothing(values: Values) -> Self {
        Self::new(values, NoConflictTarget, DoNothing, NoWhereClause {})
    }
}

impl<Values, Target, Action, WhereClause> OnConflictValues<Values, Target, Action, WhereClause> {
    pub(crate) fn new(
        values: Values,
        target: Target,

Review comment (suggestion):
```suggestion
pub struct OnConflictValues<Values, Target, Action, WhereClause = NoWhereClause> {
```

That makes it backward compatible with the old definition

Code after:
use super::on_conflict_actions::*;
use super::on_conflict_target::*;
use crate::backend::sql_dialect;
use crate::backend::Backend;
use crate::insertable::*;
use crate::query_builder::where_clause::{NoWhereClause, WhereClause};
use crate::query_builder::*;
use crate::result::QueryResult;

#[doc(hidden)]
#[derive(Debug, Clone, Copy)]
pub struct OnConflictValues<Values, Target, Action, WhereClause = NoWhereClause> {
    values: Values,
    target: Target,
    action: Action,
    /// Allow to apply filters on ON CONFLICT ... DO UPDATE ... WHERE ...
    where_clause: WhereClause,
}

impl<Values, Target, Action, WhereClause> QueryId
    for OnConflictValues<Values, Target, Action, WhereClause>
{
    type QueryId = ();

    const HAS_STATIC_QUERY_ID: bool = false;
}

impl<Values> OnConflictValues<Values, NoConflictTarget, DoNothing, NoWhereClause> {
    pub(crate) fn do_nothing(values: Values) -> Self {
        Self::new(values, NoConflictTarget, DoNothing, NoWhereClause)
    }
}

impl<Values, Target, Action, WhereClause> OnConflictValues<Values, Target, Action, WhereClause> {
    pub(crate) fn new(
        values: Values,
        target: Target,
Repository: diesel-rs/diesel
File: diesel/src/query_builder/upsert/on_conflict_clause.rs (Rust)

Code before:
use crate::insertable::*;
use crate::query_builder::where_clause::NoWhereClause;
use crate::query_builder::*;
use crate::result::QueryResult;

#[doc(hidden)]
#[derive(Debug, Clone, Copy)]
pub struct OnConflictValues<Values, Target, Action, WhereClause> {
    values: Values,
    target: Target,
    action: Action,
    /// Allow to apply filters on ON CONFLICT ... DO UPDATE ... WHERE ...
    where_clause: WhereClause,
}

impl<Values, Target, Action, WhereClause> QueryId
    for OnConflictValues<Values, Target, Action, WhereClause>
{
    type QueryId = ();

    const HAS_STATIC_QUERY_ID: bool = false;
}

impl<Values> OnConflictValues<Values, NoConflictTarget, DoNothing, NoWhereClause> {
    pub(crate) fn do_nothing(values: Values) -> Self {
        Self::new(values, NoConflictTarget, DoNothing, NoWhereClause {})
    }
}

impl<Values, Target, Action, WhereClause> OnConflictValues<Values, Target, Action, WhereClause> {
    pub(crate) fn new(
        values: Values,
        target: Target,
        action: Action,
        where_clause: WhereClause,
    ) -> Self {
        OnConflictValues {
            values,
            target,
            action,
            where_clause,
        }
    }

    pub(crate) fn replace_where<Where, F>(
        self,
        f: F,
    ) -> OnConflictValues<Values, Target, Action, Where>
    where
        F: FnOnce(WhereClause) -> Where,
    {

Review comment (suggestion):
```suggestion
        Self::new(values, NoConflictTarget, DoNothing, NoWhereClause)
```

as that's the idiomatic way to instance zero sized structs

Code after:
use crate::insertable::*;
use crate::query_builder::where_clause::{NoWhereClause, WhereClause};
use crate::query_builder::*;
use crate::result::QueryResult;

#[doc(hidden)]
#[derive(Debug, Clone, Copy)]
pub struct OnConflictValues<Values, Target, Action, WhereClause = NoWhereClause> {
    values: Values,
    target: Target,
    action: Action,
    /// Allow to apply filters on ON CONFLICT ... DO UPDATE ... WHERE ...
    where_clause: WhereClause,
}

impl<Values, Target, Action, WhereClause> QueryId
    for OnConflictValues<Values, Target, Action, WhereClause>
{
    type QueryId = ();

    const HAS_STATIC_QUERY_ID: bool = false;
}

impl<Values> OnConflictValues<Values, NoConflictTarget, DoNothing, NoWhereClause> {
    pub(crate) fn do_nothing(values: Values) -> Self {
        Self::new(values, NoConflictTarget, DoNothing, NoWhereClause)
    }
}

impl<Values, Target, Action, WhereClause> OnConflictValues<Values, Target, Action, WhereClause> {
    pub(crate) fn new(
        values: Values,
        target: Target,
        action: Action,
        where_clause: WhereClause,
    ) -> Self {
        OnConflictValues {
            values,
            target,
            action,
            where_clause,
        }
    }

    pub(crate) fn replace_where<Where, F>(
        self,
        f: F,
    ) -> OnConflictValues<Values, Target, Action, Where>
    where
        F: FnOnce(WhereClause) -> Where,
    {
Repository: diesel-rs/diesel
File: diesel_cli/src/migrations/mod.rs (Rust)

Code before:
                 .collect::<HashMap<_, _>>();

            let mut migrations = reverted_versions
                .into_iter()
                .map(|v| {
                    migrations
                        .remove(&v)
                        .ok_or_else(|| MigrationError::UnknownMigrationVersion(v.as_owned()))
                })
                .collect::<Result<Vec<_>, _>>()?;
            // Sort the migrations by version to apply them in order.
            migrations.sort_by_key(|m| m.name().version().as_owned());

            harness.run_migrations(&migrations)?;

            Ok(())
        };

    if !should_use_not_use_transaction && should_redo_migration_in_transaction(conn) {
        conn.transaction(|conn| migrations_inner(&mut HarnessWithOutput::write_to_stdout(conn)))
            .unwrap_or_else(handle_error);
    } else {
        migrations_inner(&mut HarnessWithOutput::write_to_stdout(conn))
            .unwrap_or_else(handle_error);
    }
}

#[cfg(feature = "mysql")]
fn should_redo_migration_in_transaction(t: &dyn Any) -> bool {
    !matches!(
        t.downcast_ref::<InferConnection>(),
        Some(InferConnection::Mysql(_))
    )
}

#[cfg(not(feature = "mysql"))]
fn should_redo_migration_in_transaction(_t: &dyn Any) -> bool {
    true
}


Review comment (suggestion):
since there are circumstances now when migrations won't be redone as a transaction, the comment on line 266 and 267 needs to be changed.

Code after:
             let mut migrations = MigrationSource::<DB>::migrations(&migrations_dir)
                 .unwrap_or_else(handle_error)
                 .into_iter()
                 .map(|m| (m.name().version().as_owned(), m))
                 .collect::<HashMap<_, _>>();

            // build a list of migrations that need to be applied
            let mut migrations = reverted_versions
                .into_iter()
                .map(|v| {
                    migrations
                        .remove(&v)
                        .ok_or_else(|| MigrationError::UnknownMigrationVersion(v.as_owned()))
                })
                .collect::<Result<Vec<_>, _>>()?;

            // Sort the migrations by version to apply them in order.
            migrations.sort_by_key(|m| m.name().version().as_owned());

            // apply all outstanding migrations
            harness.run_migrations(&migrations)?;

            Ok(())
        };

    if !should_use_not_use_transaction && should_redo_migration_in_transaction(conn) {
        conn.transaction(|conn| migrations_inner(&mut HarnessWithOutput::write_to_stdout(conn)))
            .unwrap_or_else(handle_error);
    } else {
        migrations_inner(&mut HarnessWithOutput::write_to_stdout(conn))
            .unwrap_or_else(handle_error);
    }
}

#[cfg(feature = "mysql")]
fn should_redo_migration_in_transaction(t: &dyn Any) -> bool {
    !matches!(
        t.downcast_ref::<InferConnection>(),
        Some(InferConnection::Mysql(_))
    )
}

#[cfg(not(feature = "mysql"))]
fn should_redo_migration_in_transaction(_t: &dyn Any) -> bool {
    true
}
Repository: diesel-rs/diesel
File: diesel/src/expression_methods/bool_expression_methods.rs (Rust)

Code before:
/// generic parameters are:
/// - If this trait isn't implemented for the `other` parameter of the expression
///   (in that case the user (you?) probably wants to implement it)
/// - If the user actually was using the not-preferred implementation of `AsExpression`
///   (e.g. towards `Nullable<Bool>` instead of `Bool`)
pub trait PreferredBoolSqlType {
    /// The preferred `Bool` SQL type for this AsExpression implementation.
    ///
    /// That should be either `Bool` or `Nullable<Bool>`.
    type PreferredSqlType;
}
impl<E: Expression> PreferredBoolSqlType for E
where
    E::SqlType: BoolOrNullableBool,
{
    type PreferredSqlType = <E as Expression>::SqlType;
}
/// This impl has to live in Diesel because otherwise it would conflict with the blanket impl above
/// because "diesel might add an implementation of Expression for bool"
impl PreferredBoolSqlType for bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for &bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for &&bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
impl PreferredBoolSqlType for &Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
impl PreferredBoolSqlType for &&Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}


Review comment (suggestion):
```suggestion

impl PreferredBoolSqlType for &bool {
```

Code after:
/// generic parameters are:
/// - If this trait isn't implemented for the `other` parameter of the expression
///   (in that case the user (you?) probably wants to implement it)
/// - If the user actually was using the not-preferred implementation of `AsExpression`
///   (e.g. towards `Nullable<Bool>` instead of `Bool`)
pub trait PreferredBoolSqlType {
    /// The preferred `Bool` SQL type for this AsExpression implementation.
    ///
    /// That should be either `Bool` or `Nullable<Bool>`.
    type PreferredSqlType;
}

impl<E: Expression> PreferredBoolSqlType for E
where
    E::SqlType: BoolOrNullableBool,
{
    type PreferredSqlType = <E as Expression>::SqlType;
}

/// This impl has to live in Diesel because otherwise it would conflict with the blanket impl above
/// because "diesel might add an implementation of Expression for bool"
impl PreferredBoolSqlType for bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for &bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for &&bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}

impl PreferredBoolSqlType for &Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}

impl PreferredBoolSqlType for &&Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
Repository: diesel-rs/diesel
File: diesel/src/expression_methods/bool_expression_methods.rs (Rust)

Code before:
///   (e.g. towards `Nullable<Bool>` instead of `Bool`)
pub trait PreferredBoolSqlType {
    /// The preferred `Bool` SQL type for this AsExpression implementation.
    ///
    /// That should be either `Bool` or `Nullable<Bool>`.
    type PreferredSqlType;
}
impl<E: Expression> PreferredBoolSqlType for E
where
    E::SqlType: BoolOrNullableBool,
{
    type PreferredSqlType = <E as Expression>::SqlType;
}
/// This impl has to live in Diesel because otherwise it would conflict with the blanket impl above
/// because "diesel might add an implementation of Expression for bool"
impl PreferredBoolSqlType for bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for &bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for &&bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
impl PreferredBoolSqlType for &Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
impl PreferredBoolSqlType for &&Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}


Review comment (suggestion):
```suggestion

impl PreferredBoolSqlType for &&bool {
```

Code after:
///   (e.g. towards `Nullable<Bool>` instead of `Bool`)
pub trait PreferredBoolSqlType {
    /// The preferred `Bool` SQL type for this AsExpression implementation.
    ///
    /// That should be either `Bool` or `Nullable<Bool>`.
    type PreferredSqlType;
}

impl<E: Expression> PreferredBoolSqlType for E
where
    E::SqlType: BoolOrNullableBool,
{
    type PreferredSqlType = <E as Expression>::SqlType;
}

/// This impl has to live in Diesel because otherwise it would conflict with the blanket impl above
/// because "diesel might add an implementation of Expression for bool"
impl PreferredBoolSqlType for bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for &bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for &&bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}

impl PreferredBoolSqlType for &Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}

impl PreferredBoolSqlType for &&Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
Repository: diesel-rs/diesel
File: diesel/src/expression_methods/bool_expression_methods.rs (Rust)

Code before:
    /// That should be either `Bool` or `Nullable<Bool>`.
    type PreferredSqlType;
}
impl<E: Expression> PreferredBoolSqlType for E
where
    E::SqlType: BoolOrNullableBool,
{
    type PreferredSqlType = <E as Expression>::SqlType;
}
/// This impl has to live in Diesel because otherwise it would conflict with the blanket impl above
/// because "diesel might add an implementation of Expression for bool"
impl PreferredBoolSqlType for bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for &bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for &&bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
impl PreferredBoolSqlType for &Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
impl PreferredBoolSqlType for &&Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}


Review comment (suggestion):
```suggestion

impl PreferredBoolSqlType for Option<bool> {
```

Code after:
    /// That should be either `Bool` or `Nullable<Bool>`.
    type PreferredSqlType;
}

impl<E: Expression> PreferredBoolSqlType for E
where
    E::SqlType: BoolOrNullableBool,
{
    type PreferredSqlType = <E as Expression>::SqlType;
}

/// This impl has to live in Diesel because otherwise it would conflict with the blanket impl above
/// because "diesel might add an implementation of Expression for bool"
impl PreferredBoolSqlType for bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for &bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for &&bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}

impl PreferredBoolSqlType for &Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}

impl PreferredBoolSqlType for &&Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
Repository: diesel-rs/diesel
File: diesel/src/expression_methods/bool_expression_methods.rs (Rust)

Code before:
where
    E::SqlType: BoolOrNullableBool,
{
    type PreferredSqlType = <E as Expression>::SqlType;
}
/// This impl has to live in Diesel because otherwise it would conflict with the blanket impl above
/// because "diesel might add an implementation of Expression for bool"
impl PreferredBoolSqlType for bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for &bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for &&bool {
    type PreferredSqlType = sql_types::Bool;
}
impl PreferredBoolSqlType for Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
impl PreferredBoolSqlType for &Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
impl PreferredBoolSqlType for &&Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}


Review comment (suggestion):
```suggestion

impl PreferredBoolSqlType for &Option<bool> {
```

Code after:
impl<E: Expression> PreferredBoolSqlType for E
where
    E::SqlType: BoolOrNullableBool,
{
    type PreferredSqlType = <E as Expression>::SqlType;
}

/// This impl has to live in Diesel because otherwise it would conflict with the blanket impl above
/// because "diesel might add an implementation of Expression for bool"
impl PreferredBoolSqlType for bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for &bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for &&bool {
    type PreferredSqlType = sql_types::Bool;
}

impl PreferredBoolSqlType for Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}

impl PreferredBoolSqlType for &Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}

impl PreferredBoolSqlType for &&Option<bool> {
    type PreferredSqlType = sql_types::Nullable<sql_types::Bool>;
}
Repository: diesel-rs/diesel
File: diesel_derives/tests/queryable.rs (Rust)

Code before:
    let data = select(sql::<(Integer, Integer)>("1, 2")).get_result(conn);
    assert_eq!(Ok(MyStruct(1, 2)), data);
}

#[test]
fn tuple_struct_without_column_name_annotations() {
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Queryable)]
    struct MyStruct(i32, i32);

    let conn = &mut connection();
    let data = select(sql::<(Integer, Integer)>("1, 2")).get_result(conn);
    assert_eq!(Ok(MyStruct(1, 2)), data);
}

#[test]
fn multiple_tables() {
    #[derive(Debug, Clone, PartialEq, Eq, Queryable)]
    #[diesel(table_name = users)]
    #[diesel(table_name = users_)]
    struct NewUser {
        name: String,
        hair_color: String,
    }

    let conn = &mut connection();
    let data = select(sql::<(String, String)>("'red', 'red'")).get_result(conn);
    assert_eq!(
        Ok(NewUser {
            name: "red".to_string(),
            hair_color: "red".to_string()
        }),
        data
    );
}


Review comment (suggestion):
```suggestion
    let data = select(sql::<(diesel::sql_types::Text, diesel::sql_types::Text)>("'red', 'red'")).get_result(conn);
```

Code after:
    let data = select(sql::<(Integer, Integer)>("1, 2")).get_result(conn);
    assert_eq!(Ok(MyStruct(1, 2)), data);
}

#[test]
fn tuple_struct_without_column_name_annotations() {
    #[derive(Debug, Clone, Copy, PartialEq, Eq, Queryable)]
    struct MyStruct(i32, i32);

    let conn = &mut connection();
    let data = select(sql::<(Integer, Integer)>("1, 2")).get_result(conn);
    assert_eq!(Ok(MyStruct(1, 2)), data);
}

#[test]
fn multiple_tables() {
    #[derive(Debug, Clone, PartialEq, Eq, Queryable)]
    #[diesel(table_name = users)]
    #[diesel(table_name = users_)]
    struct NewUser {
        name: String,
        hair_color: String,
    }

    let conn = &mut connection();
    let data = select(sql::<(diesel::sql_types::Text, diesel::sql_types::Text)>(
        "'red', 'red'",
    ))
    .get_result(conn);
    assert_eq!(
        Ok(NewUser {
            name: "red".to_string(),
            hair_color: "red".to_string()
        }),
        data
    );
}
Repository: diesel-rs/diesel
File: diesel/src/sqlite/connection/serialized_database.rs (Rust)

Code before:
#![allow(unsafe_code)]
extern crate libsqlite3_sys as ffi;

/// `SerializedDatabase` is a wrapper for a serialized database that is dynamically allocated by calling `sqlite3_serialize`.
/// This RAII wrapper is necessary to deallocate the memory when it goes out of scope with `sqlite3_free`.
#[derive(Debug)]
pub struct SerializedDatabase {
    data: *mut u8,
    len: usize,
}

impl SerializedDatabase {
    /// Creates a new `SerializedDatabase` with the given data pointer and length.
    pub fn new(data: *mut u8, len: usize) -> Self {
        Self { data, len }
    }

    /// Returns a slice of the serialized database.
    pub fn as_slice(&self) -> &[u8] {
        unsafe { std::slice::from_raw_parts(self.data, self.len) }
    }
}

impl Drop for SerializedDatabase {
    /// Deallocates the memory of the serialized database when it goes out of scope.
    fn drop(&mut self) {
        unsafe {
            // Call the FFI function to free the memory
            ffi::sqlite3_free(self.data as _);
        }
    }
}


Review comment (suggestion):
I would like to see an additional comment on this unsafe block that the pointer is never null because we don't pass the `NO_COPY` flag.

Code after:
#![allow(unsafe_code)]
extern crate libsqlite3_sys as ffi;

use std::ops::Deref;

/// `SerializedDatabase` is a wrapper for a serialized database that is dynamically allocated by calling `sqlite3_serialize`.
/// This RAII wrapper is necessary to deallocate the memory when it goes out of scope with `sqlite3_free`.
#[derive(Debug)]
pub struct SerializedDatabase {
    data: *mut u8,
    len: usize,
}

impl SerializedDatabase {
    /// Creates a new `SerializedDatabase` with the given data pointer and length.
    pub fn new(data: *mut u8, len: usize) -> Self {
        Self { data, len }
    }

    /// Returns a slice of the serialized database.
    pub fn as_slice(&self) -> &[u8] {
        // The pointer is never null because we don't pass the NO_COPY flag
        unsafe { std::slice::from_raw_parts(self.data, self.len) }
    }
}

impl Deref for SerializedDatabase {
    type Target = [u8];

    fn deref(&self) -> &Self::Target {
        self.as_slice()
    }
}

impl Drop for SerializedDatabase {
    /// Deallocates the memory of the serialized database when it goes out of scope.
    fn drop(&mut self) {
        unsafe {
            ffi::sqlite3_free(self.data as _);
        }
    }
}