Skip to content

Commit 6e7d7fc

Browse files
committed
Update tests
1 parent ae042f8 commit 6e7d7fc

File tree

8 files changed

+2256
-73
lines changed

8 files changed

+2256
-73
lines changed

jdbc/src/main/java/tech/ydb/jdbc/context/StreamQueryResult.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package tech.ydb.jdbc.context;
22

3+
import java.sql.ResultSet;
34
import java.sql.SQLException;
5+
import java.sql.SQLFeatureNotSupportedException;
46
import java.sql.Statement;
57
import java.util.ArrayList;
68
import java.util.Arrays;
@@ -276,11 +278,11 @@ public void addResultSet(ResultSetReader rsr) throws InterruptedException {
276278

277279
@Override
278280
protected ValueReader getValue(int columnIndex) throws SQLException {
279-
try {
280-
return current.getColumn(columnIndex);
281-
} catch (IllegalStateException ex) {
281+
if (current == null) {
282282
throw new SQLException(YdbConst.INVALID_ROW + rowIndex);
283283
}
284+
285+
return current.getColumn(columnIndex);
284286
}
285287

286288
@Override
@@ -296,6 +298,10 @@ public boolean next() throws SQLException {
296298
}
297299

298300
if (isCompleted && readers.isEmpty()) {
301+
current = null;
302+
if (rowsCount.get() > 0) {
303+
rowIndex = rowsCount.intValue() + 1;
304+
}
299305
return false;
300306
}
301307

@@ -337,67 +343,69 @@ public boolean isClosed() throws SQLException {
337343

338344
@Override
339345
public boolean isBeforeFirst() throws SQLException {
340-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
346+
return rowsCount.get() > 0 && rowIndex < 1;
341347
}
342348

343349
@Override
344350
public boolean isAfterLast() throws SQLException {
345-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
351+
return isCompleted && rowsCount.get() > 0 && rowIndex > rowsCount.intValue();
346352
}
347353

348354
@Override
349355
public boolean isFirst() throws SQLException {
350-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
356+
return rowIndex == 1;
351357
}
352358

353359
@Override
354360
public boolean isLast() throws SQLException {
355-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
361+
return isCompleted && rowsCount.get() > 0 && rowIndex == rowsCount.intValue();
356362
}
357363

358364
@Override
359365
public void beforeFirst() throws SQLException {
360-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
366+
throw new SQLFeatureNotSupportedException(YdbConst.FORWARD_ONLY_MODE);
361367
}
362368

363369
@Override
364370
public void afterLast() throws SQLException {
365-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
371+
throw new SQLFeatureNotSupportedException(YdbConst.FORWARD_ONLY_MODE);
366372
}
367373

368374
@Override
369375
public boolean first() throws SQLException {
370-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
376+
throw new SQLFeatureNotSupportedException(YdbConst.FORWARD_ONLY_MODE);
371377
}
372378

373379
@Override
374380
public boolean last() throws SQLException {
375-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
381+
throw new SQLFeatureNotSupportedException(YdbConst.FORWARD_ONLY_MODE);
376382
}
377383

378384
@Override
379385
public boolean absolute(int row) throws SQLException {
380-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
386+
throw new SQLFeatureNotSupportedException(YdbConst.FORWARD_ONLY_MODE);
381387
}
382388

383389
@Override
384390
public boolean relative(int rows) throws SQLException {
385-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
391+
throw new SQLFeatureNotSupportedException(YdbConst.FORWARD_ONLY_MODE);
386392
}
387393

388394
@Override
389395
public boolean previous() throws SQLException {
390-
throw new SQLException(YdbConst.FORWARD_ONLY_MODE);
396+
throw new SQLFeatureNotSupportedException(YdbConst.FORWARD_ONLY_MODE);
391397
}
392398

393399
@Override
394400
public void setFetchDirection(int direction) throws SQLException {
395-
throw new UnsupportedOperationException("Not supported yet.");
401+
if (direction != ResultSet.FETCH_FORWARD) {
402+
throw new SQLFeatureNotSupportedException(YdbConst.FORWARD_ONLY_MODE);
403+
}
396404
}
397405

398406
@Override
399407
public int getFetchDirection() throws SQLException {
400-
throw new UnsupportedOperationException("Not supported yet.");
408+
return ResultSet.FETCH_FORWARD;
401409
}
402410
}
403411
}

jdbc/src/test/java/tech/ydb/jdbc/impl/YdbConnectionImplTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,8 @@ public void fullScanAnalyzerStatementTest() throws SQLException {
10171017
TableAssert.ResultSetAssert check = sa.check(rs).assertMetaColumns();
10181018

10191019
check.nextRow(
1020-
sa.sql("select * from ydb_connection_test"),
1021-
sa.yql("select * from ydb_connection_test"),
1020+
sa.sql("select * from ydb_connection_test order by key"),
1021+
sa.yql("select * from ydb_connection_test order by key"),
10221022
sa.isFullScan(), sa.isNotError(), sa.executed(1), sa.hasAst(), sa.hasPlan()
10231023
).assertAll();
10241024

@@ -1034,8 +1034,8 @@ public void fullScanAnalyzerStatementTest() throws SQLException {
10341034
TableAssert.ResultSetAssert check = sa.check(rs).assertMetaColumns();
10351035

10361036
check.nextRow(
1037-
sa.sql("select * from ydb_connection_test"),
1038-
sa.yql("select * from ydb_connection_test"),
1037+
sa.sql("select * from ydb_connection_test order by key"),
1038+
sa.yql("select * from ydb_connection_test order by key"),
10391039
sa.isFullScan(), sa.isNotError(), sa.executed(1), sa.hasAst(), sa.hasPlan()
10401040
).assertAll();
10411041

@@ -1063,8 +1063,8 @@ public void fullScanAnalyzerStatementTest() throws SQLException {
10631063
).assertAll();
10641064

10651065
check.nextRow(
1066-
sa.sql("select * from ydb_connection_test"),
1067-
sa.yql("select * from ydb_connection_test"),
1066+
sa.sql("select * from ydb_connection_test order by key"),
1067+
sa.yql("select * from ydb_connection_test order by key"),
10681068
sa.isFullScan(), sa.isNotError(), sa.executed(1), sa.hasAst(), sa.hasPlan()
10691069
).assertAll();
10701070

0 commit comments

Comments
 (0)