| 407 | } |
| 408 | |
| 409 | int SqlFile_Impl::getNextIndex(const std::string& t_tableName, const std::string& t_columnName) { |
| 410 | // Interestingly, you CANNOT bind any database identifier (such as the table name / column name) but only litteral values... |
| 411 | // boost::optional<int> maxindex = execAndReturnFirstInt("SELECT MAX( ? ) FROM ?", t_columnName, t_tableName); |
| 412 | std::string query = "SELECT MAX(" + t_columnName + ") FROM " + t_tableName + ";"; |
| 413 | boost::optional<int> maxindex = execAndReturnFirstInt(query); |
| 414 | |
| 415 | if (maxindex) { |
| 416 | return *maxindex + 1; |
| 417 | } else { |
| 418 | return 1; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | openstudio::path SqlFile_Impl::path() const { |
| 423 | return m_path; |
nothing calls this directly
no test coverage detected