Skip to content
6 changes: 6 additions & 0 deletions glib/adbc-glib/database.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@ GADBCDatabase* gadbc_database_new(GError** error) {
AdbcStatusCode status_code = AdbcDatabaseNew(&(priv->adbc_database), &adbc_error);
priv->initialized =
gadbc_error_check(error, status_code, &adbc_error, "[adbc][database][new]");
if (priv->initialized) {
status_code = AdbcDriverManagerDatabaseSetLoadFlags(
&(priv->adbc_database), GADBC_LOAD_FLAGS_DEFAULT, &adbc_error);
priv->initialized = gadbc_error_check(error, status_code, &adbc_error,
"[adbc][database][set-load-flags]");
}
if (!priv->initialized) {
g_object_unref(database);
return NULL;
Expand Down
2 changes: 1 addition & 1 deletion glib/adbc-glib/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ typedef enum {
} GADBCLoadFlags;

/**
* GADBC_LOAD_FLAGAS_DEFAULT:
* GADBC_LOAD_FLAGS_DEFAULT:
*
* The default GADBCLoadFlags.
*
Expand Down
3 changes: 2 additions & 1 deletion ruby/lib/adbc/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
module ADBC
class Database
class << self
def open(**options)
def open(load_flags: nil, **options)
database = new
need_release = true
begin
options.each do |key, value|
database.set_option(key, value)
end
database.set_load_flags(load_flags) unless load_flags.nil?
database.init
if block_given?
yield(database)
Expand Down
63 changes: 63 additions & 0 deletions ruby/test/test-database.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

class DatabaseTest < Test::Unit::TestCase
sub_test_case(".open") do
sub_test_case("manifest") do
def setup
Dir.mktmpdir do |tmpdir|
File.write(File.join(tmpdir, "testdriver.toml"), <<~TOML)
name = "test driver"
version = "0.1.0"

[Driver]
shared = "adbc_driver_sqlite"
TOML
driver_path, ENV["ADBC_DRIVER_PATH"] = ENV["ADBC_DRIVER_PATH"], tmpdir
begin
yield
ensure
ENV["ADBC_DRIVER_PATH"] = driver_path
end
end
end
Comment thread
amoeba marked this conversation as resolved.

def test_search_env_finds_driver
ADBC::Database.open(driver: "testdriver",
uri: ":memory:",
load_flags: :search_env) do |database|
database.connect do |connection|
assert_equal([
Arrow::Table.new("1" => Arrow::Int64Array.new([1])),
-1,
],
connection.query("SELECT 1"))
end
end
end

def test_no_flags_cannot_find_driver
assert_raise(ADBC::Error::NotFound) do
ADBC::Database.open(driver: "testdriver",
uri: ":memory:",
load_flags: 0) do |_database|
end
end
end
end
end
end
Loading