Skip to content

Commit c042b4a

Browse files
authored
Fix error message for update_entity! when no instance is found for the given id (#38)
1 parent d4fa81b commit c042b4a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "PostgresORM"
22
uuid = "748b5efa-ed57-4836-b183-a38105a77fdd"
33
authors = ["Vincent Laugier <vincent.laugier@gmail.com>"]
4-
version = "0.6.0"
4+
version = "0.6.1"
55

66
[deps]
77
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"

src/Controller/coreORM.update.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,17 @@ function update_entity!(updated_object::IEntity,
310310
dbconn)
311311

312312
if length(previous_state) == 0
313-
throw(DomainError("Unable to retrieve an object of type[$data_type] "
314-
* "with id[$(getproperty(updated_object,
315-
orm_module.id_property))] from the database."
316-
*" Remind that only existing existing objects can be updated."))
313+
314+
id_for_display = util_get_ids_cols_names_and_values(updated_object, dbconn) |>
315+
dict -> join(["$k: $v" for (k, v) in dict], ", ")
316+
317+
throw(
318+
DomainError(
319+
"Unable to retrieve an object of type[$data_type] "
320+
*"with id[$id_for_display] "
321+
*"from the database. Remind that only existing objects can be updated."
322+
)
323+
)
317324
end
318325

319326
previous_state = previous_state[1]

0 commit comments

Comments
 (0)