|
44 | 44 | import com.datastax.oss.driver.api.core.metrics.DefaultSessionMetric; |
45 | 45 | import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException; |
46 | 46 | import com.datastax.oss.driver.api.core.type.DataTypes; |
| 47 | +import com.datastax.oss.driver.api.testinfra.ScyllaOnly; |
47 | 48 | import com.datastax.oss.driver.api.testinfra.ccm.CcmBridge; |
48 | 49 | import com.datastax.oss.driver.api.testinfra.ccm.CcmRule; |
49 | 50 | import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement; |
@@ -681,6 +682,38 @@ private void should_return_null_routing_information_when_single_partition_key_is |
681 | 682 | assertThat(boundStatement.getRoutingKey()).isNull(); |
682 | 683 | } |
683 | 684 |
|
| 685 | + /** |
| 686 | + * Verifies driver behavior when a prepared statement is created on a node that does not support |
| 687 | + * the metadata ID feature, but later executed on a node that does. In this scenario, the metadata |
| 688 | + * ID is {@code null}, yet the feature flag is enabled. The test ensures that such a mixed-node |
| 689 | + * situation is handled gracefully without errors. |
| 690 | + */ |
| 691 | + @Test |
| 692 | + @ScyllaOnly |
| 693 | + @SuppressWarnings("ConstantConditions") |
| 694 | + public void should_handle_empty_metadata_id_when_executing_statement_when_supported() { |
| 695 | + // given |
| 696 | + CqlSession session = sessionRule.session(); |
| 697 | + PreparedStatement preparedStatement = |
| 698 | + session.prepare("SELECT * FROM prepared_statement_test WHERE a = ?"); |
| 699 | + if (hasNoScyllaMetadataIdSupport()) { |
| 700 | + assertThat(preparedStatement.getResultMetadataId()).isNull(); |
| 701 | + } else { |
| 702 | + assertThat(preparedStatement.getResultMetadataId()).isNotNull(); |
| 703 | + preparedStatement.setResultMetadata(null, preparedStatement.getResultSetDefinitions()); |
| 704 | + } |
| 705 | + |
| 706 | + // when |
| 707 | + session.execute(preparedStatement.bind(1)); |
| 708 | + |
| 709 | + // then |
| 710 | + if (hasNoScyllaMetadataIdSupport()) { |
| 711 | + assertThat(preparedStatement.getResultMetadataId()).isNull(); |
| 712 | + } else { |
| 713 | + assertThat(preparedStatement.getResultMetadataId()).isNotNull(); |
| 714 | + } |
| 715 | + } |
| 716 | + |
684 | 717 | private static Iterable<Row> firstPageOf(CompletionStage<AsyncResultSet> stage) { |
685 | 718 | return CompletableFutures.getUninterruptibly(stage).currentPage(); |
686 | 719 | } |
|
0 commit comments