diff options
| -rw-r--r-- | libdbpp/connection.cpp | 7 | ||||
| -rw-r--r-- | libdbpp/connection.h | 15 | ||||
| -rw-r--r-- | libdbpp/tablepatch.cpp | 8 | ||||
| -rw-r--r-- | libdbpp/tablepatch.h | 37 | ||||
| -rw-r--r-- | libdbpp/unittests/testPatch.cpp | 1 | 
5 files changed, 40 insertions, 28 deletions
diff --git a/libdbpp/connection.cpp b/libdbpp/connection.cpp index 79f7d32..aaa7591 100644 --- a/libdbpp/connection.cpp +++ b/libdbpp/connection.cpp @@ -68,13 +68,6 @@ DB::Connection::insertId() const  	throw std::runtime_error("insertId not implemented for this driver.");  } -DB::TablePatch::TablePatch() : -	insteadOfDelete(nullptr), -	where(nullptr), -	order(nullptr) -{ -} -  std::string  DB::TransactionRequired::message() const throw()  { diff --git a/libdbpp/connection.h b/libdbpp/connection.h index ac18c24..7ee1bc9 100644 --- a/libdbpp/connection.h +++ b/libdbpp/connection.h @@ -16,9 +16,9 @@ namespace AdHoc {  namespace DB {  	class Command; -	class SqlWriter;  	class SelectCommand;  	class ModifyCommand; +	class TablePatch;  	enum BulkDeleteStyle {  		BulkDeleteUsingSubSelect, @@ -57,19 +57,6 @@ namespace DB {  			const time_t FailureTime;  	}; -	class DLL_PUBLIC TablePatch { -		public: -			TablePatch(); - -			TableName src; -			TableName dest; -			PrimaryKey pk; -			ColumnNames cols; -			SqlWriter * insteadOfDelete; -			SqlWriter * where; -			SqlWriter * order; -	}; -  	/// Exception thrown when finishing a connection that still has a transaction open.  	class DLL_PUBLIC TransactionStillOpen : public AdHoc::StdException {  		private: diff --git a/libdbpp/tablepatch.cpp b/libdbpp/tablepatch.cpp index 1aea416..114a2b4 100644 --- a/libdbpp/tablepatch.cpp +++ b/libdbpp/tablepatch.cpp @@ -1,12 +1,20 @@  #include "connection.h"  #include "modifycommand.h"  #include "selectcommand.h" +#include "tablepatch.h"  #include "sqlWriter.h"  #include <buffer.h>  #include <safeMapFind.h>  #include <scopeExit.h>  #include <boost/algorithm/string/join.hpp> +DB::TablePatch::TablePatch() : +	insteadOfDelete(nullptr), +	where(nullptr), +	order(nullptr) +{ +} +  DB::PatchResult  DB::Connection::patchTable(TablePatch * tp)  { diff --git a/libdbpp/tablepatch.h b/libdbpp/tablepatch.h index 9615b5c..b197254 100644 --- a/libdbpp/tablepatch.h +++ b/libdbpp/tablepatch.h @@ -8,15 +8,38 @@  #include <modifycommand.h>  #include <selectcommand.h> -class TablePatch { -	public: +namespace DB { +	class SqlWriter; +	/// Table patch settings. +	class DLL_PUBLIC TablePatch { +		private: +			typedef std::string TableName; +			typedef std::string ColumnName; +			typedef std::set<ColumnName> ColumnNames; +			typedef ColumnNames PrimaryKey; +			typedef PrimaryKey::const_iterator PKI; -	private: -		void            doDeletes(DynamicSql::SqlWriterPtr insteadOfDelete, DynamicSql::SqlWriterPtr where, DynamicSql::SqlWriterPtr order); -		void            doUpdates(DynamicSql::SqlWriterPtr where, DynamicSql::SqlWriterPtr order); -		void            doInserts(DynamicSql::SqlWriterPtr order); -}; +		public: +			/// Default constructor +			TablePatch(); + +			/// Source table name. +			TableName src; +			/// Destination table name. +			TableName dest; +			/// Columns comprising the [effective] primary key. +			PrimaryKey pk; +			/// Columns to be updated in the path. +			ColumnNames cols; +			/// An optional SQL writer to replace the default delete operation. +			SqlWriter * insteadOfDelete; +			/// An optional SQL writer to append a where clause. +			SqlWriter * where; +			/// An optional SQL writer to append an order by clause. +			SqlWriter * order; +	}; +}  #endif diff --git a/libdbpp/unittests/testPatch.cpp b/libdbpp/unittests/testPatch.cpp index a393f8c..2b44d07 100644 --- a/libdbpp/unittests/testPatch.cpp +++ b/libdbpp/unittests/testPatch.cpp @@ -5,6 +5,7 @@  #include <definedDirs.h>  #include <pq-mock.h>  #include <command.h> +#include <tablepatch.h>  #include <sqlWriter.h>  #include <buffer.h>  | 
