diff options
| author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-04-21 00:01:09 +0100 | 
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-04-25 21:27:48 +0100 | 
| commit | bfeb1b43bc13abdfa46d459a79b26d71d98db9bf (patch) | |
| tree | 0f8c52b352ed7ea0a723a9286d2ff46dccc44311 | |
| parent | Add file processing framework and category meta processor (diff) | |
| download | gentoobrowse-api-bfeb1b43bc13abdfa46d459a79b26d71d98db9bf.tar.bz2 gentoobrowse-api-bfeb1b43bc13abdfa46d459a79b26d71d98db9bf.tar.xz gentoobrowse-api-bfeb1b43bc13abdfa46d459a79b26d71d98db9bf.zip | |
Move category maint SQL to .sql files
4 files changed, 13 insertions, 3 deletions
| diff --git a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp index 01f27f1..93c08f0 100644 --- a/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/categoryMetaProcessor.cpp @@ -3,6 +3,9 @@  #include "fileUtils.h"  #include "xmlUtils.h"  #include "dbUtils.h" +#include <sql/maintenance/categoryInsert.sql.h> +#include <sql/maintenance/categoryUpdate.sql.h> +#include <sql/maintenance/categoryDelete.sql.h>  namespace U = Gentoo::Utils;  using namespace Gentoo::Utils::File; @@ -14,7 +17,7 @@ namespace Gentoo {  		void  		CategoryMetaProcessor::created(DB::Connection * dbc, const boost::filesystem::path & fn, const boost::filesystem::path & path) const  		{ -			upsert(dbc->modify("INSERT INTO gentoobrowse.categories(summary, name) VALUES(?, ?)"), fn, path); +			upsert(dbc->modify(sql::maintenance::categoryInsert::sql), fn, path);  		}  		void @@ -32,13 +35,13 @@ namespace Gentoo {  		void  		CategoryMetaProcessor::modified(DB::Connection * dbc, const boost::filesystem::path & fn, const boost::filesystem::path & path) const  		{ -			upsert(dbc->modify("UPDATE gentoobrowse.categories SET summary = ? WHERE name = ?)"), fn, path); +			upsert(dbc->modify(sql::maintenance::categoryUpdate::sql), fn, path);  		}  		void  		CategoryMetaProcessor::deleted(DB::Connection * dbc, const boost::filesystem::path & fn) const  		{ -			auto m = dbc->modify("DELETE FROM gentoobrowse.categories WHERE name = ?"); +			auto m = dbc->modify(sql::maintenance::categoryDelete::sql);  			m->bindParamS(0, (fn / 1).string());  			m->execute();  		} diff --git a/gentoobrowse-api/service/sql/maintenance/categoryDelete.sql b/gentoobrowse-api/service/sql/maintenance/categoryDelete.sql new file mode 100644 index 0000000..ad961c8 --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/categoryDelete.sql @@ -0,0 +1,2 @@ +DELETE FROM gentoobrowse.categories +WHERE name = ? diff --git a/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql b/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql new file mode 100644 index 0000000..8c3f685 --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/categoryInsert.sql @@ -0,0 +1,2 @@ +INSERT INTO gentoobrowse.categories(summary, name) +VALUES(?, ?) diff --git a/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql b/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql new file mode 100644 index 0000000..1b0ef38 --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/categoryUpdate.sql @@ -0,0 +1,3 @@ +UPDATE gentoobrowse.categories SET +	summary = ? +WHERE name = ? | 
