@Ignore @Test(expected = SQLException.class) public void testThatQuotedTableNameInFromIsCaseSensitive() throws SQLException { String input = "SELECT * FROM 'Users'"; rewrite(input); }
public String rewrite(String query) throws SQLException { if (query == null) { throw new IllegalArgumentException("You must specify specify a 'query'."); } State state = new State(query); for (state.cursor = 0; state.cursor < query.length(); state.cursor++) { char currentCharacter = query.charAt(state.cursor); switch (currentCharacter) { case '\'': case '\"': case '`': Character onStack = state.stack.peekFirst(); if (onStack != null && onStack.equals(currentCharacter)) { state.stack.removeFirst(); } else { state.stack.addFirst(currentCharacter); } processWordStartOrMiddle(state); break; case ' ': case ',': case ';': if (state.stack.isEmpty()) { processWordEnding(state); } processWordStartOrMiddle(state); break; default: processWordStartOrMiddle(state); break; } } processWordEnding(state); return state.output.toString(); }
PostgresqlQueryRewriter implements QueryRewriter { public String rewrite(String query) throws SQLException { if (query == null) { throw new IllegalArgumentException("You must specify specify a 'query'."); } State state = new State(query); for (state.cursor = 0; state.cursor < query.length(); state.cursor++) { char currentCharacter = query.charAt(state.cursor); switch (currentCharacter) { case '\'': case '\"': case '`': Character onStack = state.stack.peekFirst(); if (onStack != null && onStack.equals(currentCharacter)) { state.stack.removeFirst(); } else { state.stack.addFirst(currentCharacter); } processWordStartOrMiddle(state); break; case ' ': case ',': case ';': if (state.stack.isEmpty()) { processWordEnding(state); } processWordStartOrMiddle(state); break; default: processWordStartOrMiddle(state); break; } } processWordEnding(state); return state.output.toString(); } }
PostgresqlQueryRewriter implements QueryRewriter { public String rewrite(String query) throws SQLException { if (query == null) { throw new IllegalArgumentException("You must specify specify a 'query'."); } State state = new State(query); for (state.cursor = 0; state.cursor < query.length(); state.cursor++) { char currentCharacter = query.charAt(state.cursor); switch (currentCharacter) { case '\'': case '\"': case '`': Character onStack = state.stack.peekFirst(); if (onStack != null && onStack.equals(currentCharacter)) { state.stack.removeFirst(); } else { state.stack.addFirst(currentCharacter); } processWordStartOrMiddle(state); break; case ' ': case ',': case ';': if (state.stack.isEmpty()) { processWordEnding(state); } processWordStartOrMiddle(state); break; default: processWordStartOrMiddle(state); break; } } processWordEnding(state); return state.output.toString(); } PostgresqlQueryRewriter(); }
PostgresqlQueryRewriter implements QueryRewriter { public String rewrite(String query) throws SQLException { if (query == null) { throw new IllegalArgumentException("You must specify specify a 'query'."); } State state = new State(query); for (state.cursor = 0; state.cursor < query.length(); state.cursor++) { char currentCharacter = query.charAt(state.cursor); switch (currentCharacter) { case '\'': case '\"': case '`': Character onStack = state.stack.peekFirst(); if (onStack != null && onStack.equals(currentCharacter)) { state.stack.removeFirst(); } else { state.stack.addFirst(currentCharacter); } processWordStartOrMiddle(state); break; case ' ': case ',': case ';': if (state.stack.isEmpty()) { processWordEnding(state); } processWordStartOrMiddle(state); break; default: processWordStartOrMiddle(state); break; } } processWordEnding(state); return state.output.toString(); } PostgresqlQueryRewriter(); void setTableMapping(Map<String, String> newTableMapping); String rewrite(String query); }
PostgresqlQueryRewriter implements QueryRewriter { public String rewrite(String query) throws SQLException { if (query == null) { throw new IllegalArgumentException("You must specify specify a 'query'."); } State state = new State(query); for (state.cursor = 0; state.cursor < query.length(); state.cursor++) { char currentCharacter = query.charAt(state.cursor); switch (currentCharacter) { case '\'': case '\"': case '`': Character onStack = state.stack.peekFirst(); if (onStack != null && onStack.equals(currentCharacter)) { state.stack.removeFirst(); } else { state.stack.addFirst(currentCharacter); } processWordStartOrMiddle(state); break; case ' ': case ',': case ';': if (state.stack.isEmpty()) { processWordEnding(state); } processWordStartOrMiddle(state); break; default: processWordStartOrMiddle(state); break; } } processWordEnding(state); return state.output.toString(); } PostgresqlQueryRewriter(); void setTableMapping(Map<String, String> newTableMapping); String rewrite(String query);  }