assertj-db icon indicating copy to clipboard operation
assertj-db copied to clipboard

Changes: The statement did not return a result set.

Open bhargavkumar-65 opened this issue 1 year ago • 1 comments

I am trying to update a table in my ms sqlserver db, below is my code.

	Source source = new Source("//SourceConnectionString");
	Changes change = new Changes();
	change.setRequest(new Request(source, "UPDATE CM_GENERATOR SET GEN_VALUE='3'"));

when i execute above code, i am getting below error

org.assertj.db.exception.AssertJDBException: com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.

at org.assertj.db.type.AbstractDbData.load(AbstractDbData.java:136)
at org.assertj.db.type.AbstractDbData.getPksNameList(AbstractDbData.java:255)
at org.assertj.db.type.Changes.getDuplicatedRequest(Changes.java:244)
at org.assertj.db.type.Changes.setRequest(Changes.java:159)


    <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-db</artifactId>
        <version>2.0.2</version>
    </dependency>

bhargavkumar-65 avatar Nov 08 '24 04:11 bhargavkumar-65

Hi @bhargavkumar-65 , Indeed the request should be a SELECT and return result to be compared between setStartPointNow() and setEndPointNow().

A full examples :

Source source = new Source("//SourceConnectionString");
Changes change = new Changes();
change.setRequest(new Request(source, "SELECT * FROM xxx;"));
change.setStartPointNow();
update("update test set c1 = 1;");
changes.setEndPointNow();
assertThat(changes).hasNumberOfChanges(1);

VanRoy avatar Nov 14 '24 13:11 VanRoy