mirror of
				https://github.com/ohwgiles/laminar.git
				synced 2025-06-13 12:54:29 +00:00 
			
		
		
		
	fix for new non-COW std::strings
This commit is contained in:
		
							parent
							
								
									c502bdfdc3
								
							
						
					
					
						commit
						7b7de751e3
					
				| @ -50,14 +50,14 @@ void Database::Statement::bindValue(int i, const char* e) { | |||||||
|     sqlite3_bind_text(stmt, i, e, -1, NULL); |     sqlite3_bind_text(stmt, i, e, -1, NULL); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Database::Statement::bindValue(int i, std::string e) { | void Database::Statement::bindValue(int i, const std::string& e) { | ||||||
|     sqlite3_bind_blob(stmt, i, e.data(), e.size(), NULL); |     sqlite3_bind_text(stmt, i, e.data(), e.size(), NULL); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| template<> std::string Database::Statement::fetchColumn(int col) { | template<> std::string Database::Statement::fetchColumn(int col) { | ||||||
|     int sz = sqlite3_column_bytes(stmt, col); |     int sz = sqlite3_column_bytes(stmt, col); | ||||||
|     std::string res(sz, '\0'); |     std::string res(sz, '\0'); | ||||||
|     memcpy(&res[0], sqlite3_column_blob(stmt, col), sz); |     memcpy(&res[0], sqlite3_column_text(stmt, col), sz); | ||||||
|     return res; |     return res; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -55,9 +55,12 @@ private: | |||||||
|         ~Statement(); |         ~Statement(); | ||||||
| 
 | 
 | ||||||
|         // Bind several parameters in a single call. They are bound
 |         // Bind several parameters in a single call. They are bound
 | ||||||
|         // by index in the order passed into this function
 |         // by index in the order passed into this function. Must be
 | ||||||
|  |         // passed by reference because arguments may be std::strings,
 | ||||||
|  |         // which must be passed by reference because sqlite requires
 | ||||||
|  |         // the bound string's lifetime to exist until sqlite3_step
 | ||||||
|         template<typename...Args> |         template<typename...Args> | ||||||
|         Statement& bind(Args...args) { |         Statement& bind(const Args&...args) { | ||||||
|             return bindRecursive<Args...>(1, args...); |             return bindRecursive<Args...>(1, args...); | ||||||
|         } |         } | ||||||
|         // Fetch columns. Supply a callback that will be executed for
 |         // Fetch columns. Supply a callback that will be executed for
 | ||||||
| @ -100,7 +103,7 @@ private: | |||||||
|         bool row(); |         bool row(); | ||||||
| 
 | 
 | ||||||
|         template<typename T, typename...Args> |         template<typename T, typename...Args> | ||||||
|         Statement& bindRecursive(int i, T v, Args...args) { |         Statement& bindRecursive(int i, const T& v, const Args&...args) { | ||||||
|             bindValue(i, v); // specialization must exist for T
 |             bindValue(i, v); // specialization must exist for T
 | ||||||
|             return bindRecursive(i + 1, args...); |             return bindRecursive(i + 1, args...); | ||||||
|         } |         } | ||||||
| @ -112,7 +115,7 @@ private: | |||||||
|         // Bind value specializations
 |         // Bind value specializations
 | ||||||
|         void bindValue(int i, int e); |         void bindValue(int i, int e); | ||||||
|         void bindValue(int i, const char* e); |         void bindValue(int i, const char* e); | ||||||
|         void bindValue(int i, std::string e); |         void bindValue(int i, const std::string& e); | ||||||
| 
 | 
 | ||||||
|         // Declaration for fetch column interface,
 |         // Declaration for fetch column interface,
 | ||||||
|         // intentionally missing definition
 |         // intentionally missing definition
 | ||||||
|  | |||||||
| @ -669,9 +669,10 @@ void Laminar::runFinished(Run * r) { | |||||||
|             (unsigned char*)&r->log[0], logsize); |             (unsigned char*)&r->log[0], logsize); | ||||||
|     zipped.resize(zippedSize); |     zipped.resize(zippedSize); | ||||||
| 
 | 
 | ||||||
|  |     std::string reason = r->reason(); | ||||||
|     db->stmt("INSERT INTO builds VALUES(?,?,?,?,?,?,?,?,?,?,?,?)") |     db->stmt("INSERT INTO builds VALUES(?,?,?,?,?,?,?,?,?,?,?,?)") | ||||||
|      .bind(r->name, r->build, node->name, r->queuedAt, r->startedAt, completedAt, int(r->result), |      .bind(r->name, r->build, node->name, r->queuedAt, r->startedAt, completedAt, int(r->result), | ||||||
|            zipped, logsize, r->parentName, r->parentBuild, r->reason()) |            zipped, logsize, r->parentName, r->parentBuild, reason) | ||||||
|      .exec(); |      .exec(); | ||||||
| 
 | 
 | ||||||
|     // notify clients
 |     // notify clients
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user