fernandobatels / rsfbclient

Rust Firebird Client
MIT License
76 stars 11 forks source link

Create_database not respect dialect selectioned. #150

Closed almir-lima closed 10 months ago

almir-lima commented 11 months ago

The create database method is only generating databases with Dialect 1 in Firebird 4.0. The code:

#[macro_export]
macro_rules! fb_client_hosted {
    () => {
        println!("Name of database is required.")
    };
    ($fbclient: expr,
     $host: expr,
     $port: expr,
     $database : expr) => {
        rsfbclient::builder_native()
            .with_dyn_load($fbclient)
            .with_remote()
            .host($host)
            .port($port)
            .db_name($database)
            .dialect(rsfbclient::Dialect::D3)
            .charset(rsfbclient::charset::UTF_8)
            .user("SYSDBA")
            .pass("masterkey") // Not necessary to embedded mode
            .page_size(8 * 1024) // Optional
            .page_size(16384)
    };
}

pub fn create_database( lib: &str, host_name: &str, port: u16, db_name: &str) -> Result<Self, String> {
        let start = Instant::now();

        if host_name == "" {
            match (fb_client_embedded!(lib, db_name)).create_database() {
                Ok(conn) => {
                    return Ok( Dao { db: conn.into() } )
                },
                Err(er_msg) => return Err(format!("Error: {:?}", er_msg).to_string()),
            };
        } else {
            match (fb_client_hosted!(lib, host_name, port, db_name)).create_database() {
                Ok(conn) => {
                    return Ok( Dao { db: conn.into() } )
                },
                Err(er_msg) => return Err(format!("Error: {:?}", er_msg).to_string()),
            }
        };
    }

out:

called Result::unwrap() on an Err value: Sql { msg: "Dynamic SQL Error\nSQL error code = -817\nMetadata update statement is not allowed by the current database SQL dialect 1", code: -817 } note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

fernandobatels commented 10 months ago

Investigating

fernandobatels commented 10 months ago

@almir-lima Please, try my last commit

almir-lima commented 10 months ago

Hello, i runed a "cargo clean" and updated the files but it's not working. I don't know if i doing the update rigth. My declarations in dependencies is that:

[dependencies] rsfbclient = { version="*", features = ["dynamic_loading"], default-features = false }

I put wrong macro, the macro than i use is that:


#[macro_export]
macro_rules! fb_client_embedded {
    () => {
        println!("Name of database is required.")
    };
    ($fbclient: expr,
     $db : expr ) => {
        rsfbclient::builder_native()
            .with_dyn_load($fbclient)
            .with_embedded()
            .db_name($db)
            .dialect(rsfbclient::Dialect::D3)
            .charset(rsfbclient::charset::UTF_8)
            .user("SYSDBA")
    };
}
fernandobatels commented 10 months ago

Try this:

[dependencies]
rsfbclient = { git = "https://github.com/fernandobatels/rsfbclient.git", branch = "bug-150" }
fernandobatels commented 10 months ago

New version released with this fix: 0.24.0