Skip to content

Commit

Permalink
bump Project and change default vector to return get_map.
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermebodin committed Apr 8, 2024
1 parent 818605d commit a708246
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "PSRClassesInterface"
uuid = "1eab49e5-27d8-4905-b9f6-327b6ea666c4"
version = "0.14.4"
version = "0.14.5"

[deps]
DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965"
Expand Down
33 changes: 20 additions & 13 deletions src/PSRDatabaseSQLite/psri_study_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,37 @@ function _add_at_least_id_in_configurations_parameters(kwargs...)
return dict_kwargs
end

PSRI.load_study(
function PSRI.load_study(
::PSRDatabaseSQLiteInterface,
data_path::String,
) = PSRDatabaseSQLite.load_db(data_path)
)
return PSRDatabaseSQLite.load_db(data_path)
end

PSRI.load_study(
function PSRI.load_study(
::PSRDatabaseSQLiteInterface,
data_path::String,
path_migrations::String,
) = PSRDatabaseSQLite.load_db(data_path, path_migrations)
)
return PSRDatabaseSQLite.load_db(data_path, path_migrations)
end

# Read
PSRI.get_vector(
function PSRI.get_vector(
db::DatabaseSQLite,
collection::String,
attribute::String,
element_label::String;
default::Union{Nothing, Any} = nothing,
) =
PSRDatabaseSQLite.read_vector_parameter(
)
return PSRDatabaseSQLite.read_vector_parameter(
db,
collection,
attribute,
element_label;
default,
)
end

PSRI.get_vectors(db::DatabaseSQLite, collection::String, attribute::String) =
PSRDatabaseSQLite.read_vector_parameters(db, collection, attribute)
Expand Down Expand Up @@ -98,28 +103,30 @@ function PSRI.configuration_parameter(
end
end

PSRI.get_parm(
function PSRI.get_parm(
db::DatabaseSQLite,
collection::String,
attribute::String,
element_label::String;
default::Union{Nothing, Any} = nothing,
) =
PSRDatabaseSQLite.read_scalar_parameter(
)
return PSRDatabaseSQLite.read_scalar_parameter(
db,
collection,
attribute,
element_label;
default,
)
end

PSRI.get_parms(
function PSRI.get_parms(
db::DatabaseSQLite,
collection::String,
attribute::String;
default::Union{Nothing, Any} = nothing,
) =
PSRDatabaseSQLite.read_scalar_parameters(db, collection, attribute; default)
)
return PSRDatabaseSQLite.read_scalar_parameters(db, collection, attribute; default)
end

function PSRI.get_attributes(db::DatabaseSQLite, collection::String)
return PSRDatabaseSQLite._get_attribute_ids(db, collection)
Expand Down
2 changes: 1 addition & 1 deletion src/PSRDatabaseSQLite/read.jl
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function _get_scalar_relation_map(
df = DBInterface.execute(db.sqlite_db, query) |> DataFrame
results = df[!, 1]
num_results = length(results)
map_of_indexes = Vector{Int}(undef, num_results)
map_of_indexes = -1 * ones(Int, num_results)
ids_in_collection_to = read_scalar_parameters(db, collection_to, "id")
for i in 1:num_results
if ismissing(results[i])
Expand Down
2 changes: 2 additions & 0 deletions src/study_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ function max_elements end
)
Returns a `Vector{Int32}` with the map between collections given a certain [`RelationType`](@ref).
If the map is a vector [3, 2, 1] it means that the element 1 of `lst_from` is related to the element 3 of `lst_to`.
If the relation does not exist it might return -1 or some garbage value.
Examples:
Expand Down

0 comments on commit a708246

Please sign in to comment.