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

Dialect on create_database and no_db_trigger support #152

Merged
merged 3 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/createdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fn main() -> Result<(), FbError> {
.user("SYSDBA")
.pass("masterkey")
.page_size(8 * 1024) // Optional
.dialect(rsfbclient::Dialect::D1)
.create_database()?;

#[cfg(feature = "dynamic_loading")]
Expand All @@ -38,6 +39,7 @@ fn main() -> Result<(), FbError> {
.user("SYSDBA")
.pass("masterkey")
.page_size(16 * 1024) // Optional
.dialect(rsfbclient::Dialect::D3)
.create_database()?;

conn.close()?;
Expand Down
6 changes: 5 additions & 1 deletion rsfbclient-core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ pub trait FirebirdClientDbOps: Send {
fn attach_database(
&mut self,
config: &Self::AttachmentConfig,
dialect: Dialect,
no_db_triggers: bool,
) -> Result<Self::DbHandle, FbError>;

/// Disconnect from the database
Expand All @@ -50,6 +52,7 @@ pub trait FirebirdClientDbOps: Send {
&mut self,
config: &Self::AttachmentConfig,
page_size: Option<u32>,
dialect: Dialect,
) -> Result<Self::DbHandle, FbError>;
}

Expand Down Expand Up @@ -145,12 +148,13 @@ pub trait FirebirdClientDbEvents: FirebirdClientDbOps {
) -> Result<(), FbError>;
}

#[derive(Debug, Eq, PartialEq, Copy, Clone)]
#[derive(Debug, Eq, PartialEq, Copy, Clone, Default)]
#[repr(u8)]
/// Firebird sql dialect
pub enum Dialect {
D1 = 1,
D2 = 2,
#[default]
D3 = 3,
}

Expand Down
21 changes: 18 additions & 3 deletions rsfbclient-native/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,17 @@
fn attach_database(
&mut self,
config: &Self::AttachmentConfig,
dialect: Dialect,
no_db_triggers: bool,
) -> Result<NativeDbHandle, FbError> {
let (dpb, conn_string) = self.build_dpb(config);
let (mut dpb, conn_string) = self.build_dpb(config, dialect);
let mut handle = 0;

if no_db_triggers {
dpb.extend(&[ibase::isc_dpb_no_db_triggers as u8, 1 as u8]);

Check warning on line 123 in rsfbclient-native/src/connection.rs

View workflow job for this annotation

GitHub Actions / clippy

casting integer literal to `u8` is unnecessary

warning: casting integer literal to `u8` is unnecessary --> rsfbclient-native/src/connection.rs:123:63 | 123 | dpb.extend(&[ibase::isc_dpb_no_db_triggers as u8, 1 as u8]); | ^^^^^^^ help: try: `1_u8` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `#[warn(clippy::unnecessary_cast)]` on by default
dpb.extend(&[1 as u8]);

Check warning on line 124 in rsfbclient-native/src/connection.rs

View workflow job for this annotation

GitHub Actions / clippy

casting integer literal to `u8` is unnecessary

warning: casting integer literal to `u8` is unnecessary --> rsfbclient-native/src/connection.rs:124:26 | 124 | dpb.extend(&[1 as u8]); | ^^^^^^^ help: try: `1_u8` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
}

unsafe {
if self.ibase.isc_attach_database()(
&mut self.status[0],
Expand Down Expand Up @@ -162,8 +169,9 @@
&mut self,
config: &Self::AttachmentConfig,
page_size: Option<u32>,
dialect: Dialect,
) -> Result<NativeDbHandle, FbError> {
let (mut dpb, conn_string) = self.build_dpb(config);
let (mut dpb, conn_string) = self.build_dpb(config, dialect);
let mut handle = 0;

if let Some(ps) = page_size {
Expand Down Expand Up @@ -214,7 +222,7 @@
];
if let TrLockResolution::Wait(Some(time)) = confs.lock_resolution {
tpb.push(ibase::isc_tpb_lock_timeout as u8);
tpb.push(4 as u8);

Check warning on line 225 in rsfbclient-native/src/connection.rs

View workflow job for this annotation

GitHub Actions / clippy

casting integer literal to `u8` is unnecessary

warning: casting integer literal to `u8` is unnecessary --> rsfbclient-native/src/connection.rs:225:22 | 225 | tpb.push(4 as u8); | ^^^^^^^ help: try: `4_u8` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
tpb.extend_from_slice(&time.to_le_bytes());
}

Expand Down Expand Up @@ -506,7 +514,7 @@
}
}

Ok(affected as usize)

Check warning on line 517 in rsfbclient-native/src/connection.rs

View workflow job for this annotation

GitHub Actions / clippy

casting to the same type is unnecessary (`usize` -> `usize`)

warning: casting to the same type is unnecessary (`usize` -> `usize`) --> rsfbclient-native/src/connection.rs:517:12 | 517 | Ok(affected as usize) | ^^^^^^^^^^^^^^^^^ help: try: `affected` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
}

fn fetch(
Expand Down Expand Up @@ -668,7 +676,11 @@
/// Build the dpb and the connection string
///
/// Used by attach database operations
fn build_dpb(&mut self, config: &NativeFbAttachmentConfig) -> (Vec<u8>, String) {
fn build_dpb(
&mut self,
config: &NativeFbAttachmentConfig,
dialect: Dialect,
) -> (Vec<u8>, String) {
let user = &config.user;
let mut password = None;
let db_name = &config.db_name;
Expand Down Expand Up @@ -709,6 +721,9 @@
dpb.extend(role.bytes());
}

dpb.extend(&[ibase::isc_dpb_sql_dialect as u8, 1 as u8]);

Check warning on line 724 in rsfbclient-native/src/connection.rs

View workflow job for this annotation

GitHub Actions / clippy

casting integer literal to `u8` is unnecessary

warning: casting integer literal to `u8` is unnecessary --> rsfbclient-native/src/connection.rs:724:60 | 724 | dpb.extend(&[ibase::isc_dpb_sql_dialect as u8, 1 as u8]); | ^^^^^^^ help: try: `1_u8` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
dpb.extend(&[dialect as u8]);

dpb
};

Expand Down
18 changes: 15 additions & 3 deletions rsfbclient-rust/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,18 @@
fn attach_database(
&mut self,
config: &Self::AttachmentConfig,
dialect: Dialect,
no_db_triggers: bool,
) -> Result<RustDbHandle, FbError> {
let host = config.host.as_str();
let port = config.port;
let db_name = config.db_name.as_str();
let user = config.user.as_str();
let pass = config.pass.as_str();
let role = match &config.role_name {
Some(ro) => Some(ro.as_str()),
None => None,
};

Check warning on line 99 in rsfbclient-rust/src/client.rs

View workflow job for this annotation

GitHub Actions / clippy

manual implementation of `Option::map`

warning: manual implementation of `Option::map` --> rsfbclient-rust/src/client.rs:96:20 | 96 | let role = match &config.role_name { | ____________________^ 97 | | Some(ro) => Some(ro.as_str()), 98 | | None => None, 99 | | }; | |_________^ help: try: `config.role_name.as_ref().map(|ro| ro.as_str())` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map = note: `#[warn(clippy::manual_map)]` on by default

// Take the existing connection, or connects
let mut conn = match self.conn.take() {
Expand All @@ -109,7 +111,8 @@
)?,
};

let attach_result = conn.attach_database(db_name, user, pass, role);
let attach_result =
conn.attach_database(db_name, user, pass, role, dialect, no_db_triggers);

// Put the connection back
self.conn.replace(conn);
Expand All @@ -135,16 +138,17 @@
&mut self,
config: &Self::AttachmentConfig,
page_size: Option<u32>,
dialect: Dialect,
) -> Result<RustDbHandle, FbError> {
let host = config.host.as_str();
let port = config.port;
let db_name = config.db_name.as_str();
let user = config.user.as_str();
let pass = config.pass.as_str();
let role = match &config.role_name {
Some(ro) => Some(ro.as_str()),
None => None,
};

Check warning on line 151 in rsfbclient-rust/src/client.rs

View workflow job for this annotation

GitHub Actions / clippy

manual implementation of `Option::map`

warning: manual implementation of `Option::map` --> rsfbclient-rust/src/client.rs:148:20 | 148 | let role = match &config.role_name { | ____________________^ 149 | | Some(ro) => Some(ro.as_str()), 150 | | None => None, 151 | | }; | |_________^ help: try: `config.role_name.as_ref().map(|ro| ro.as_str())` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map

// Take the existing connection, or connects
let mut conn = match self.conn.take() {
Expand All @@ -159,7 +163,7 @@
)?,
};

let attach_result = conn.create_database(db_name, user, pass, page_size, role);
let attach_result = conn.create_database(db_name, user, pass, page_size, role, dialect);

// Put the connection back
self.conn.replace(conn);
Expand Down Expand Up @@ -391,6 +395,7 @@
pass: &str,
page_size: Option<u32>,
role_name: Option<&str>,
dialect: Dialect,
) -> Result<DbHandle, FbError> {
self.socket.write_all(&create(
db_name,
Expand All @@ -399,7 +404,8 @@
self.version,
self.charset.clone(),
page_size,
role_name.clone(),

Check warning on line 407 in rsfbclient-rust/src/client.rs

View workflow job for this annotation

GitHub Actions / clippy

using `clone` on type `Option<&str>` which implements the `Copy` trait

warning: using `clone` on type `Option<&str>` which implements the `Copy` trait --> rsfbclient-rust/src/client.rs:407:13 | 407 | role_name.clone(), | ^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `role_name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy = note: `#[warn(clippy::clone_on_copy)]` on by default
dialect,
))?;
self.socket.flush()?;

Expand All @@ -415,6 +421,8 @@
user: &str,
pass: &str,
role_name: Option<&str>,
dialect: Dialect,
no_db_triggers: bool,
) -> Result<DbHandle, FbError> {
self.socket.write_all(&attach(
db_name,
Expand All @@ -422,7 +430,9 @@
pass,
self.version,
self.charset.clone(),
role_name.clone(),

Check warning on line 433 in rsfbclient-rust/src/client.rs

View workflow job for this annotation

GitHub Actions / clippy

using `clone` on type `Option<&str>` which implements the `Copy` trait

warning: using `clone` on type `Option<&str>` which implements the `Copy` trait --> rsfbclient-rust/src/client.rs:433:13 | 433 | role_name.clone(), | ^^^^^^^^^^^^^^^^^ help: try removing the `clone` call: `role_name` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#clone_on_copy
dialect,
no_db_triggers,
))?;
self.socket.flush()?;

Expand Down Expand Up @@ -465,7 +475,7 @@
];
if let TrLockResolution::Wait(Some(time)) = confs.lock_resolution {
tpb.push(ibase::isc_tpb_lock_timeout as u8);
tpb.push(4 as u8);

Check warning on line 478 in rsfbclient-rust/src/client.rs

View workflow job for this annotation

GitHub Actions / clippy

casting integer literal to `u8` is unnecessary

warning: casting integer literal to `u8` is unnecessary --> rsfbclient-rust/src/client.rs:478:22 | 478 | tpb.push(4 as u8); | ^^^^^^^ help: try: `4_u8` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
tpb.extend_from_slice(&time.to_le_bytes());
}

Expand Down Expand Up @@ -1042,7 +1052,9 @@
let mut conn =
FirebirdWireConnection::connect("127.0.0.1", 3050, db_name, user, pass, UTF_8).unwrap();

let mut db_handle = conn.attach_database(db_name, user, pass, None).unwrap();
let mut db_handle = conn
.attach_database(db_name, user, pass, None, Dialect::D3, false)
.unwrap();

let mut tr_handle = conn
.begin_transaction(&mut db_handle, TransactionConfiguration::default())
Expand Down
30 changes: 27 additions & 3 deletions rsfbclient-rust/src/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
util::*,
xsqlda::{XSqlVar, XSQLDA_DESCRIBE_VARS},
};
use rsfbclient_core::{ibase, Charset, Column, FbError, FreeStmtOp, SqlType, TrOp};
use rsfbclient_core::{ibase, Charset, Column, Dialect, FbError, FreeStmtOp, SqlType, TrOp};

/// Buffer length to use in the connection
pub const BUFFER_LENGTH: u32 = 1024;
Expand Down Expand Up @@ -132,15 +132,26 @@
}

/// Attach request
pub fn attach(
db_name: &str,
user: &str,
pass: &str,
protocol: ProtocolVersion,
charset: Charset,
role_name: Option<&str>,
dialect: Dialect,
no_db_triggers: bool,
) -> Bytes {

Check warning on line 144 in rsfbclient-rust/src/wire.rs

View workflow job for this annotation

GitHub Actions / clippy

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7) --> rsfbclient-rust/src/wire.rs:135:1 | 135 | / pub fn attach( 136 | | db_name: &str, 137 | | user: &str, 138 | | pass: &str, ... | 143 | | no_db_triggers: bool, 144 | | ) -> Bytes { | |__________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments = note: `#[warn(clippy::too_many_arguments)]` on by default
let dpb = build_dpb(user, pass, protocol, charset, None, role_name);
let dpb = build_dpb(
user,
pass,
protocol,
charset,
None,
role_name,
dialect,
no_db_triggers,
);

let mut attach = BytesMut::with_capacity(16 + db_name.len() + dpb.len());

Expand All @@ -155,16 +166,19 @@
}

/// Create db request
pub fn create(
db_name: &str,
user: &str,
pass: &str,
protocol: ProtocolVersion,
charset: Charset,
page_size: Option<u32>,
role_name: Option<&str>,
dialect: Dialect,
) -> Bytes {

Check warning on line 178 in rsfbclient-rust/src/wire.rs

View workflow job for this annotation

GitHub Actions / clippy

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7) --> rsfbclient-rust/src/wire.rs:169:1 | 169 | / pub fn create( 170 | | db_name: &str, 171 | | user: &str, 172 | | pass: &str, ... | 177 | | dialect: Dialect, 178 | | ) -> Bytes { | |__________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
let dpb = build_dpb(user, pass, protocol, charset, page_size, role_name);
let dpb = build_dpb(
user, pass, protocol, charset, page_size, role_name, dialect, false,
);

let mut create = BytesMut::with_capacity(16 + db_name.len() + dpb.len());

Expand All @@ -179,14 +193,16 @@
}

/// Dpb builder
fn build_dpb(
user: &str,
pass: &str,
protocol: ProtocolVersion,
charset: Charset,
page_size: Option<u32>,
role_name: Option<&str>,
dialect: Dialect,
no_db_triggers: bool,
) -> Bytes {

Check warning on line 205 in rsfbclient-rust/src/wire.rs

View workflow job for this annotation

GitHub Actions / clippy

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7) --> rsfbclient-rust/src/wire.rs:196:1 | 196 | / fn build_dpb( 197 | | user: &str, 198 | | pass: &str, 199 | | protocol: ProtocolVersion, ... | 204 | | no_db_triggers: bool, 205 | | ) -> Bytes { | |__________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
let mut dpb = BytesMut::with_capacity(64);

dpb.put_u8(1); //Version
Expand All @@ -209,6 +225,14 @@
dpb.extend(role.bytes());
}

dpb.extend(&[ibase::isc_dpb_sql_dialect as u8, 1 as u8]);

Check warning on line 228 in rsfbclient-rust/src/wire.rs

View workflow job for this annotation

GitHub Actions / clippy

casting integer literal to `u8` is unnecessary

warning: casting integer literal to `u8` is unnecessary --> rsfbclient-rust/src/wire.rs:228:52 | 228 | dpb.extend(&[ibase::isc_dpb_sql_dialect as u8, 1 as u8]); | ^^^^^^^ help: try: `1_u8` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
dpb.extend(&[dialect as u8]);

if no_db_triggers {
dpb.extend(&[ibase::isc_dpb_no_db_triggers as u8, 1 as u8]);

Check warning on line 232 in rsfbclient-rust/src/wire.rs

View workflow job for this annotation

GitHub Actions / clippy

casting integer literal to `u8` is unnecessary

warning: casting integer literal to `u8` is unnecessary --> rsfbclient-rust/src/wire.rs:232:59 | 232 | dpb.extend(&[ibase::isc_dpb_no_db_triggers as u8, 1 as u8]); | ^^^^^^^ help: try: `1_u8` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
dpb.extend(&[1 as u8]);

Check warning on line 233 in rsfbclient-rust/src/wire.rs

View workflow job for this annotation

GitHub Actions / clippy

casting integer literal to `u8` is unnecessary

warning: casting integer literal to `u8` is unnecessary --> rsfbclient-rust/src/wire.rs:233:22 | 233 | dpb.extend(&[1 as u8]); | ^^^^^^^ help: try: `1_u8` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
}

match protocol {
// Plaintext password
ProtocolVersion::V10 => {
Expand Down
6 changes: 6 additions & 0 deletions src/connection/builders/builder_native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ where
self.conn_conf.transaction_conf = builder(&mut transaction_builder()).build();
self
}

/// Disabled the database triggers
pub fn no_db_triggers(&mut self) -> &mut Self {
self.conn_conf.no_db_triggers = true;
self
}
}

impl<A, B> NativeConnectionBuilder<A, B> {
Expand Down
6 changes: 6 additions & 0 deletions src/connection/builders/builder_pure_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ impl PureRustConnectionBuilder {
self
}

/// Disabled the database triggers
pub fn no_db_triggers(&mut self) -> &mut Self {
self.0.no_db_triggers = true;
self
}

/// Default transaction configuration
pub fn transaction(&mut self, conf: TransactionConfiguration) -> &mut Self {
self.0.transaction_conf = conf;
Expand Down
7 changes: 5 additions & 2 deletions src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub trait FirebirdClientFactory {
pub struct ConnectionConfiguration<A> {
attachment_conf: A,
dialect: Dialect,
no_db_triggers: bool,
stmt_cache_size: usize,
transaction_conf: TransactionConfiguration,
}
Expand All @@ -71,6 +72,7 @@ impl<A: Default> Default for ConnectionConfiguration<A> {
dialect: Dialect::D3,
stmt_cache_size: 20,
transaction_conf: TransactionConfiguration::default(),
no_db_triggers: false,
}
}
}
Expand Down Expand Up @@ -107,7 +109,8 @@ impl<C: FirebirdClient> Connection<C> {
mut cli: C,
conf: &ConnectionConfiguration<C::AttachmentConfig>,
) -> Result<Connection<C>, FbError> {
let handle = cli.attach_database(&conf.attachment_conf)?;
let handle =
cli.attach_database(&conf.attachment_conf, conf.dialect, conf.no_db_triggers)?;
let stmt_cache = StmtCache::new(conf.stmt_cache_size);

Ok(Connection {
Expand All @@ -127,7 +130,7 @@ impl<C: FirebirdClient> Connection<C> {
conf: &ConnectionConfiguration<C::AttachmentConfig>,
page_size: Option<u32>,
) -> Result<Connection<C>, FbError> {
let handle = cli.create_database(&conf.attachment_conf, page_size)?;
let handle = cli.create_database(&conf.attachment_conf, page_size, conf.dialect)?;
let stmt_cache = StmtCache::new(conf.stmt_cache_size);

Ok(Connection {
Expand Down
40 changes: 40 additions & 0 deletions src/tests/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
mk_tests_default! {
#[allow(unused_imports)]
use crate::*;
use std::time::SystemTime;

Check warning on line 10 in src/tests/connection.rs

View workflow job for this annotation

GitHub Actions / embedded (dynamic_loading)

unused import: `std::time::SystemTime`

Check warning on line 10 in src/tests/connection.rs

View workflow job for this annotation

GitHub Actions / embedded (linking)

unused import: `std::time::SystemTime`

Check warning on line 10 in src/tests/connection.rs

View workflow job for this annotation

GitHub Actions / embedded (dynamic_loading)

unused import: `std::time::SystemTime`

#[test]
#[cfg(all(feature = "linking", not(feature = "embedded_tests"), not(feature = "pure_rust")))]
Expand Down Expand Up @@ -309,4 +309,44 @@

Ok(())
}

#[test]
#[cfg(all(not(feature = "embedded_tests")))]
fn no_db_triggers() -> Result<(), FbError> {

let epoch = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_nanos();

let mut conn = cbuilder()
.connect()?;

conn.execute(&format!("create table log_conn{} (id int);", epoch), ())?;

conn.execute(&format!("create trigger trig_conexao{0} on connect as begin insert into log_conn{0} (id) values (5); end", epoch), ())?;

conn.close()?;

let mut conn2 = cbuilder()
.no_db_triggers()
.connect()?;

let resp: Option<(i32,)> = conn2.query_first(&format!("select * from log_conn{}", epoch), ())?;
assert_eq!(None, resp);

conn2.close()?;

let mut conn3 = cbuilder()
.connect()?;

let resp: Option<(i32,)> = conn3.query_first(&format!("select * from log_conn{}", epoch), ())?;
assert_eq!(Some((5,)), resp);

conn3.execute(&format!("drop trigger trig_conexao{};", epoch), ()).ok();
conn3.execute(&format!("drop table log_conn{};", epoch), ()).ok();
conn3.close()?;

Ok(())
}
}
34 changes: 34 additions & 0 deletions src/tests/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,38 @@ mk_tests_default! {

Ok(())
}

#[test]
#[cfg(all(feature = "linking", not(feature = "embedded_tests"), not(feature = "pure_rust")))]
fn dyn_linking_create_with_invalid_dialect() -> Result<(), FbError> {

let rs = builder_native()
.with_dyn_link()
.with_remote()
.db_name("test_create_db5.fdb")
.user("SYSDBA")
.host("localhost")
.dialect(rsfbclient::Dialect::D2)
.create_database();

assert!(rs.is_err());
assert!(rs.err().unwrap().to_string().contains("Database dialect 2 is not a valid dialec"));

Ok(())
}

#[test]
#[cfg(all(feature = "pure_rust", not(feature = "native_client")))]
fn pure_rust_create_with_invalid_dialect() -> Result<(), FbError> {
let rs = builder_pure_rust()
.db_name("test_create_db55.fdb")
.user("SYSDBA")
.dialect(rsfbclient::Dialect::D2)
.create_database();

assert!(rs.is_err());
assert!(rs.err().unwrap().to_string().contains("Database dialect 2 is not a valid dialec"));

Ok(())
}
}
Loading