(query)
| 227 | } |
| 228 | |
| 229 | function parseDeleteQuery(query) { |
| 230 | const deleteRegex = /DELETE FROM (\w+)( WHERE (.*))?/i; |
| 231 | const match = query.match(deleteRegex); |
| 232 | |
| 233 | if (!match) { |
| 234 | throw new Error("Invalid DELETE syntax."); |
| 235 | } |
| 236 | |
| 237 | const [, table, , whereString] = match; |
| 238 | let whereClauses = []; |
| 239 | if (whereString) { |
| 240 | whereClauses = parseWhereClause(whereString); |
| 241 | } |
| 242 | |
| 243 | return { |
| 244 | type: 'DELETE', |
| 245 | table: table.trim(), |
| 246 | whereClauses |
| 247 | }; |
| 248 | } |
| 249 | |
| 250 | |
| 251 | module.exports = { parseSelectQuery, parseJoinClause, parseInsertQuery, parseDeleteQuery }; |
no test coverage detected