| 55 | } |
| 56 | |
| 57 | static std::string getCopyFilePath(const std::string& boundFilePath, const std::string& filePath) { |
| 58 | if (filePath[0] == '/' || (std::isalpha(filePath[0]) && filePath[1] == ':')) { |
| 59 | // Note: |
| 60 | // Unix absolute path starts with '/' |
| 61 | // Windows absolute path starts with "[DiskID]://" |
| 62 | // This code path is for backward compatibility, we used to export the absolute path for |
| 63 | // csv files to copy.cypher files. |
| 64 | return filePath; |
| 65 | } |
| 66 | |
| 67 | auto path = boundFilePath + "/" + filePath; |
| 68 | #if defined(_WIN32) |
| 69 | // TODO(Ziyi): This is a temporary workaround because our parser requires input cypher queries |
| 70 | // to escape all special characters in string literal. E.g. The user input query is: 'IMPORT |
| 71 | // DATABASE 'C:\\db\\uw''. The parser removes any escaped characters and this function accepts |
| 72 | // the path parameter as 'C:\db\uw'. Then the ImportDatabase operator gives the file path to |
| 73 | // antlr4 parser directly without escaping any special characters in the path, which causes a |
| 74 | // parser exception. However, the parser exception is not thrown properly which leads to the |
| 75 | // undefined behaviour. |
| 76 | size_t pos = 0; |
| 77 | while ((pos = path.find('\\', pos)) != std::string::npos) { |
| 78 | path.replace(pos, 1, "\\\\"); |
| 79 | pos += 2; |
| 80 | } |
| 81 | #endif |
| 82 | return path; |
| 83 | } |
| 84 | |
| 85 | std::unique_ptr<BoundStatement> Binder::bindImportDatabaseClause(const Statement& statement) { |
| 86 | auto& importDB = statement.constCast<ImportDB>(); |
no test coverage detected