Refactored persistence with mysql and sqlite to factorize more things with a CMS_STORAGE_SQL .. based only on sql statement execution.
Various changes
This commit is contained in:
@@ -153,22 +153,22 @@ feature -- Status Report
|
||||
end
|
||||
|
||||
connection: DATABASE_CONNECTION
|
||||
-- Database connection.
|
||||
-- Database connection.
|
||||
|
||||
db_control: DB_CONTROL
|
||||
-- Database control.
|
||||
-- Database control.
|
||||
do
|
||||
Result := connection.db_control
|
||||
end
|
||||
|
||||
db_result: detachable DB_RESULT
|
||||
-- Database query result.
|
||||
-- Database query result.
|
||||
|
||||
db_selection: detachable DB_SELECTION
|
||||
-- Database selection.
|
||||
-- Database selection.
|
||||
|
||||
db_change: detachable DB_CHANGE
|
||||
-- Database modification.
|
||||
-- Database modification.
|
||||
|
||||
feature -- Error handling
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ class
|
||||
DATABASE_QUERY
|
||||
|
||||
inherit
|
||||
|
||||
REFACTORING_HELPER
|
||||
|
||||
SHARED_LOGGER
|
||||
@@ -17,7 +16,7 @@ create
|
||||
|
||||
feature {NONE} -- Intialization
|
||||
|
||||
data_reader (a_query: STRING; a_parameters: STRING_TABLE [detachable ANY])
|
||||
data_reader (a_query: STRING; a_parameters: like parameters)
|
||||
-- SQL data reader for the query `a_query' with arguments `a_parameters'
|
||||
do
|
||||
log.write_information (generator + ".data_reader" + " execute query: " + a_query)
|
||||
@@ -65,7 +64,7 @@ feature -- Access
|
||||
query: STRING
|
||||
-- SQL query to execute.
|
||||
|
||||
parameters: STRING_TABLE [detachable ANY]
|
||||
parameters: detachable STRING_TABLE [detachable ANY]
|
||||
-- query parameters.
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
@@ -73,26 +72,24 @@ feature {NONE} -- Implementation
|
||||
set_map_name (a_base_selection: DB_EXPRESSION)
|
||||
-- Store parameters `item' and their `key'.
|
||||
do
|
||||
from
|
||||
parameters.start
|
||||
until
|
||||
parameters.after
|
||||
loop
|
||||
a_base_selection.set_map_name (parameters.item_for_iteration, parameters.key_for_iteration)
|
||||
parameters.forth
|
||||
if attached parameters as l_parameters then
|
||||
across
|
||||
l_parameters as ic
|
||||
loop
|
||||
a_base_selection.set_map_name (ic.item, ic.key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unset_map_name (a_base_selection: DB_EXPRESSION)
|
||||
-- Remove parameters item associated with key `key'.
|
||||
do
|
||||
from
|
||||
parameters.start
|
||||
until
|
||||
parameters.after
|
||||
loop
|
||||
a_base_selection.unset_map_name (parameters.key_for_iteration)
|
||||
parameters.forth
|
||||
if attached parameters as l_parameters then
|
||||
across
|
||||
l_parameters as ic
|
||||
loop
|
||||
a_base_selection.unset_map_name (ic.key)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -101,26 +98,25 @@ feature {NONE} -- Implementation
|
||||
-- exclude sensitive information.
|
||||
do
|
||||
create Result.make_empty
|
||||
from
|
||||
a_parameters.start
|
||||
until
|
||||
a_parameters.after
|
||||
loop
|
||||
Result.append ("name:")
|
||||
Result.append (a_parameters.key_for_iteration.as_string_32)
|
||||
Result.append (", value:")
|
||||
if
|
||||
a_parameters.key_for_iteration.has_substring ("Password") or else
|
||||
a_parameters.key_for_iteration.has_substring ("password")
|
||||
then
|
||||
-- Data to exclude
|
||||
else
|
||||
if attached a_parameters.item_for_iteration as l_item then
|
||||
Result.append (l_item.out)
|
||||
if a_parameters /= Void then
|
||||
across
|
||||
a_parameters as ic
|
||||
loop
|
||||
Result.append ("name:")
|
||||
Result.append (ic.key.as_string_32)
|
||||
Result.append (", value:")
|
||||
if
|
||||
ic.key.has_substring ("Password") or else
|
||||
ic.key.has_substring ("password")
|
||||
then
|
||||
-- Data to exclude
|
||||
else
|
||||
if attached ic.item as l_item then
|
||||
Result.append (l_item.out)
|
||||
end
|
||||
end
|
||||
Result.append ("%N")
|
||||
end
|
||||
Result.append ("%N")
|
||||
a_parameters.forth
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ note
|
||||
date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $"
|
||||
revision: "$Revision: 95678 $"
|
||||
EIS: "SQL server injection", "src=http://blogs.msdn.com/b/raulga/archive/2007/01/04/dynamic-sql-sql-injection.aspx", "protocol=url"
|
||||
|
||||
expanded class
|
||||
DATABASE_SQL_SERVER_ENCODER
|
||||
|
||||
@@ -12,7 +13,7 @@ inherit
|
||||
|
||||
feature -- Escape SQL input
|
||||
|
||||
encode (a_string:READABLE_STRING_32): READABLE_STRING_32
|
||||
encode (a_string: READABLE_STRING_32): READABLE_STRING_32
|
||||
-- Escape single quote (') and braces ([,]).
|
||||
local
|
||||
l_string: STRING
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Error from database"
|
||||
date: "$Date: 2013-08-08 16:39:49 -0300 (ju. 08 de ago. de 2013) $"
|
||||
revision: "$Revision: 195 $"
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
DATABASE_ERROR
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
note
|
||||
description: "Database error handler"
|
||||
date: "$Date: 2013-08-08 16:39:49 -0300 (ju. 08 de ago. de 2013) $"
|
||||
revision: "$Revision: 195 $"
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
DATABASE_ERROR_HANDLER
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {DATABASE_NO_CHANGE_ERROR}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
date: "$Date: 2014-11-13 16:23:47 +0100 (jeu., 13 nov. 2014) $"
|
||||
revision: "$Revision: 96085 $"
|
||||
|
||||
class
|
||||
DATABASE_NO_CHANGE_ERROR
|
||||
|
||||
Reference in New Issue
Block a user