Skip to content

Commit ab1b94d

Browse files
committed
RCBC-453: update bucket settings conversion from optionals
1 parent b0c36e9 commit ab1b94d

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

ext/couchbase.cxx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4679,7 +4679,9 @@ cb_extract_bucket_settings(const couchbase::core::management::cluster::bucket_se
46794679
rb_hash_aset(bucket, rb_id2sym(rb_intern("name")), cb_str_new(entry.name));
46804680
rb_hash_aset(bucket, rb_id2sym(rb_intern("uuid")), cb_str_new(entry.uuid));
46814681
rb_hash_aset(bucket, rb_id2sym(rb_intern("ram_quota_mb")), ULL2NUM(entry.ram_quota_mb));
4682-
rb_hash_aset(bucket, rb_id2sym(rb_intern("max_expiry")), ULONG2NUM(entry.max_expiry));
4682+
if (const auto &val = entry.max_expiry; val.has_value()) {
4683+
rb_hash_aset(bucket, rb_id2sym(rb_intern("max_expiry")), ULONG2NUM(val.value()));
4684+
}
46834685
switch (entry.compression_mode) {
46844686
case couchbase::core::management::cluster::bucket_compression::off:
46854687
rb_hash_aset(bucket, rb_id2sym(rb_intern("compression_mode")), rb_id2sym(rb_intern("off")));
@@ -4694,7 +4696,9 @@ cb_extract_bucket_settings(const couchbase::core::management::cluster::bucket_se
46944696
rb_hash_aset(bucket, rb_id2sym(rb_intern("compression_mode")), Qnil);
46954697
break;
46964698
}
4697-
rb_hash_aset(bucket, rb_id2sym(rb_intern("num_replicas")), ULONG2NUM(entry.num_replicas));
4699+
if (const auto &val = entry.num_replicas; val.has_value()) {
4700+
rb_hash_aset(bucket, rb_id2sym(rb_intern("num_replicas")), ULONG2NUM(val.value()));
4701+
}
46984702
rb_hash_aset(bucket, rb_id2sym(rb_intern("replica_indexes")), entry.replica_indexes ? Qtrue : Qfalse);
46994703
rb_hash_aset(bucket, rb_id2sym(rb_intern("flush_enabled")), entry.flush_enabled ? Qtrue : Qfalse);
47004704
switch (entry.eviction_policy) {
@@ -4750,8 +4754,12 @@ cb_extract_bucket_settings(const couchbase::core::management::cluster::bucket_se
47504754
rb_id2sym(rb_intern("history_retention_collection_default")),
47514755
entry.history_retention_collection_default.value() ? Qtrue : Qfalse);
47524756
}
4753-
rb_hash_aset(bucket, rb_id2sym(rb_intern("history_retention_bytes")), ULONG2NUM(entry.history_retention_bytes));
4754-
rb_hash_aset(bucket, rb_id2sym(rb_intern("history_retention_duration")), ULONG2NUM(entry.history_retention_duration));
4757+
if (const auto &val = entry.history_retention_bytes; val.has_value()) {
4758+
rb_hash_aset(bucket, rb_id2sym(rb_intern("history_retention_bytes")), ULONG2NUM(val.value()));
4759+
}
4760+
if (const auto &val = entry.history_retention_duration; val.has_value()) {
4761+
rb_hash_aset(bucket, rb_id2sym(rb_intern("history_retention_duration")), ULONG2NUM(val.value()));
4762+
}
47554763

47564764
VALUE capabilities = rb_ary_new_capa(static_cast<long>(entry.capabilities.size()));
47574765
for (const auto& capa : entry.capabilities) {

0 commit comments

Comments
 (0)