Added persistence support for Eiffel sqlite3 wrapper.

Updated existing persistency solution to be more generic to any db solution.
This commit is contained in:
2015-10-05 16:04:10 +02:00
parent 7fcacad5eb
commit eb5ae32e46
18 changed files with 859 additions and 160 deletions

View File

@@ -83,11 +83,11 @@ feature -- Persistence
if l_update then
if l_has_modif then
sql_change (sql_update_node_data, l_parameters)
sql_modify (sql_update_node_data, l_parameters)
end
else
if l_has_modif then
sql_change (sql_insert_node_data, l_parameters)
sql_insert (sql_insert_node_data, l_parameters)
else
-- no page data, means everything is empty.
-- FOR NOW: always record row
@@ -116,7 +116,7 @@ feature -- Persistence
if a_node.has_id then
create l_parameters.make (1)
l_parameters.put (a_node.id, "nid")
sql_change (sql_delete_node_data, l_parameters)
sql_modify (sql_delete_node_data, l_parameters)
end
end
@@ -136,18 +136,21 @@ feature {NONE} -- Implementation
l_parameters.put (a_node.revision, "revision")
sql_query (sql_select_node_data, l_parameters)
if not has_error then
n := sql_rows_count
if n = 1 then
if not sql_after then
-- nid, revision, tags
l_rev := sql_read_integer_64 (2)
l_tags := sql_read_string_32 (3)
if l_tags /= Void then
Result := [l_rev, l_tags]
end
else
check unique_data: n = 0 end
sql_forth
if not sql_after then
check unique_data: n = 0 end
Result := Void
end
end
end
sql_finalize
ensure
accepted_revision: Result /= Void implies Result.revision <= a_node.revision
end

View File

@@ -23,9 +23,10 @@ feature -- Access
error_handler.reset
write_information_log (generator + ".blogs_count")
sql_query (sql_select_blog_count, Void)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := sql_read_integer_64 (1)
end
sql_finalize
end
blogs_count_from_user (a_user: CMS_USER) : INTEGER_64
@@ -38,9 +39,10 @@ feature -- Access
create l_parameters.make (2)
l_parameters.put (a_user.id, "user")
sql_query (sql_select_blog_count_from_user, l_parameters)
if sql_rows_count = 1 then
if not has_error and not sql_after then
Result := sql_read_integer_64 (1)
end
sql_finalize
end
blogs: LIST [CMS_NODE]