| 52 | } |
| 53 | |
| 54 | std::string PrepareQueryForGetTables(const GetTables& command) { |
| 55 | std::stringstream table_query; |
| 56 | |
| 57 | table_query << "SELECT 'main' as catalog_name, null as schema_name, name as " |
| 58 | "table_name, type as table_type FROM sqlite_master where 1=1"; |
| 59 | |
| 60 | if (command.catalog.has_value()) { |
| 61 | table_query << " and catalog_name='" << command.catalog.value() << "'"; |
| 62 | } |
| 63 | |
| 64 | if (command.db_schema_filter_pattern.has_value()) { |
| 65 | table_query << " and schema_name LIKE '" << command.db_schema_filter_pattern.value() |
| 66 | << "'"; |
| 67 | } |
| 68 | |
| 69 | if (command.table_name_filter_pattern.has_value()) { |
| 70 | table_query << " and table_name LIKE '" << command.table_name_filter_pattern.value() |
| 71 | << "'"; |
| 72 | } |
| 73 | |
| 74 | if (!command.table_types.empty()) { |
| 75 | table_query << " and table_type IN ("; |
| 76 | size_t size = command.table_types.size(); |
| 77 | for (size_t i = 0; i < size; i++) { |
| 78 | table_query << "'" << command.table_types[i] << "'"; |
| 79 | if (size - 1 != i) { |
| 80 | table_query << ","; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | table_query << ")"; |
| 85 | } |
| 86 | |
| 87 | table_query << " order by table_name"; |
| 88 | return table_query.str(); |
| 89 | } |
| 90 | |
| 91 | template <typename Callback> |
| 92 | Status SetParametersOnSQLiteStatement(SqliteStatement* statement, |
no test coverage detected