diff --git a/Project.toml b/Project.toml index f54a4c26..0d23e60d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "PSRClassesInterface" uuid = "1eab49e5-27d8-4905-b9f6-327b6ea666c4" -version = "0.17.2" +version = "0.17.3" [deps] DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965" diff --git a/src/PSRDatabaseSQLite/collection.jl b/src/PSRDatabaseSQLite/collection.jl index 5f092f6d..2e55054c 100644 --- a/src/PSRDatabaseSQLite/collection.jl +++ b/src/PSRDatabaseSQLite/collection.jl @@ -428,6 +428,15 @@ function _get_collection_time_series_files_tables(::SQLite.DB, collection_id::St return string(collection_id, "_time_series_files") end +function _dimensions_of_time_series_group(collection::Collection, group_id::String) + time_series = collection.time_series + for (_, time_series_attribute) in time_series + if time_series_attribute.group_id == group_id + return time_series_attribute.dimension_names + end + end +end + function _validate_actions_on_foreign_key( collection_id::String, table_name::String, diff --git a/src/PSRDatabaseSQLite/create.jl b/src/PSRDatabaseSQLite/create.jl index 4ac58ac7..cc0d7463 100644 --- a/src/PSRDatabaseSQLite/create.jl +++ b/src/PSRDatabaseSQLite/create.jl @@ -210,7 +210,6 @@ function create_element!( catch e @error """ Error creating element in collection \"$collection_id\" - error message: $(e.msg) """ rethrow(e) end diff --git a/src/PSRDatabaseSQLite/validate.jl b/src/PSRDatabaseSQLite/validate.jl index 644bfcd7..b6bde3f9 100644 --- a/src/PSRDatabaseSQLite/validate.jl +++ b/src/PSRDatabaseSQLite/validate.jl @@ -364,6 +364,7 @@ function _throw_if_data_does_not_match_group( df::DataFrame, ) collection = _get_collection(db, collection_id) + dimensions_of_group = _dimensions_of_time_series_group(collection, group) dimensions_in_df = [] attributes_in_df = [] @@ -371,9 +372,13 @@ function _throw_if_data_does_not_match_group( if column in keys(collection.time_series) # should be an attribute push!(attributes_in_df, column) - else + elseif column in dimensions_of_group # should be a dimension push!(dimensions_in_df, column) + else + psr_database_sqlite_error( + "Attribute \"$column\" is not an attribute or dimension of the time series group \"$group\".", + ) end end