Skip to content

Commit

Permalink
Added ResultSetInformation.getResultMap, small fixes (p6spy#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavlyukovskiy authored Jul 26, 2020
1 parent fc1d70e commit 4ac967f
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 95 deletions.
6 changes: 4 additions & 2 deletions docs/releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
## [3.9.1](https://github.com/p6spy/p6spy/compare/p6spy-3.9.0...master) (Unreleased)

Improvements:
* [issue 501](https://github.com/p6spy/p6spy/pull/501) Database dialect dependent binary data representation.
* [issue 493](https://github.com/p6spy/p6spy/pull/493) Added `ResultSetInformation.getResultMap()`.

Defects resolved:

## [3.9.0](https://github.com/p6spy/p6spy/compare/p6spy-3.8.7...3.9.0) (Unreleased)
## [3.9.0](https://github.com/p6spy/p6spy/compare/p6spy-3.8.7...3.9.0) (2020-04-04)

Improvements:
* [issue 497](https://github.com/p6spy/p6spy/pull/497) Added `Statement` into `StatementInformation`.

Defects resolved:

## [3.8.7](https://github.com/p6spy/p6spy/compare/p6spy-3.8.6...3.8.7) (Unreleased)
## [3.8.7](https://github.com/p6spy/p6spy/compare/p6spy-3.8.6...3.8.7) (2019-12-23)

Improvements:
* [issue #492](https://github.com/p6spy/p6spy/pull/492) The `file.encoding` system property is used by default to read the configuration file, can be overriden using `-Dspy.properties.charset`.
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/com/p6spy/engine/common/ResultSetInformation.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package com.p6spy.engine.common;

import java.sql.ResultSet;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

Expand Down Expand Up @@ -47,7 +48,6 @@ public ResultSetInformation(final StatementInformation statementInformation) {
public void generateLogMessage() {
if (lastRowLogged != currRow) {
P6LogQuery.log(Category.RESULTSET, this);
resultMap.clear();
lastRowLogged = currRow;
}
}
Expand All @@ -58,6 +58,7 @@ public int getCurrRow() {

public void incrementCurrRow() {
this.currRow++;
this.resultMap.clear();
}

public void setColumnValue(String columnName, Object value) {
Expand All @@ -84,6 +85,16 @@ public String getSqlWithValues() {
return sb.toString();
}

/**
* Returns column/value map for the last row read.
*
* NOTE: Only values that were retrieved from {@link ResultSet}
* ({@link ResultSet#getString(int)}, {@link ResultSet#getBoolean(int)}, etc.) will be returned.
*/
public Map<String, Value> getResultMap() {
return Collections.unmodifiableMap(resultMap);
}

public StatementInformation getStatementInformation() {
return statementInformation;
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/p6spy/engine/wrapper/ResultSetWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ public ResultSetWrapper(ResultSet delegate, ResultSetInformation resultSetInform
resultSetInformation.setResultSet(delegate);
}

public ResultSet getDelegate() {
return delegate;
}

public ResultSetInformation getResultSetInformation() {
return resultSetInformation;
}

@Override
public boolean next() throws SQLException {
SQLException e = null;
Expand Down
Loading

0 comments on commit 4ac967f

Please sign in to comment.