@@ -4370,18 +4370,20 @@ cb_Backend_document_query(VALUE self, VALUE statement, VALUE options)
4370
4370
static void
4371
4371
cb_generate_bucket_settings (VALUE bucket, couchbase::core::management::cluster::bucket_settings& entry, bool is_create)
4372
4372
{
4373
- if (VALUE bucket_type = rb_hash_aref (bucket, rb_id2sym (rb_intern (" bucket_type" ))); TYPE (bucket_type) == T_SYMBOL) {
4374
- if (bucket_type == rb_id2sym (rb_intern (" couchbase" )) || bucket_type == rb_id2sym (rb_intern (" membase" ))) {
4375
- entry.bucket_type = couchbase::core::management::cluster::bucket_type::couchbase;
4376
- } else if (bucket_type == rb_id2sym (rb_intern (" memcached" ))) {
4377
- entry.bucket_type = couchbase::core::management::cluster::bucket_type::memcached;
4378
- } else if (bucket_type == rb_id2sym (rb_intern (" ephemeral" ))) {
4379
- entry.bucket_type = couchbase::core::management::cluster::bucket_type::ephemeral;
4373
+ if (VALUE bucket_type = rb_hash_aref (bucket, rb_id2sym (rb_intern (" bucket_type" ))); !NIL_P (bucket_type)) {
4374
+ if (TYPE (bucket_type) == T_SYMBOL) {
4375
+ if (bucket_type == rb_id2sym (rb_intern (" couchbase" )) || bucket_type == rb_id2sym (rb_intern (" membase" ))) {
4376
+ entry.bucket_type = couchbase::core::management::cluster::bucket_type::couchbase;
4377
+ } else if (bucket_type == rb_id2sym (rb_intern (" memcached" ))) {
4378
+ entry.bucket_type = couchbase::core::management::cluster::bucket_type::memcached;
4379
+ } else if (bucket_type == rb_id2sym (rb_intern (" ephemeral" ))) {
4380
+ entry.bucket_type = couchbase::core::management::cluster::bucket_type::ephemeral;
4381
+ } else {
4382
+ throw ruby_exception (rb_eArgError, rb_sprintf (" unknown bucket type, given %+" PRIsVALUE, bucket_type));
4383
+ }
4380
4384
} else {
4381
- throw ruby_exception (rb_eArgError, rb_sprintf (" unknown bucket type, given %+" PRIsVALUE, bucket_type));
4385
+ throw ruby_exception (rb_eArgError, rb_sprintf (" bucket type must be a Symbol , given %+" PRIsVALUE, bucket_type));
4382
4386
}
4383
- } else {
4384
- throw ruby_exception (rb_eArgError, rb_sprintf (" bucket type must be a Symbol, given %+" PRIsVALUE, bucket_type));
4385
4387
}
4386
4388
4387
4389
if (VALUE name = rb_hash_aref (bucket, rb_id2sym (rb_intern (" name" ))); TYPE (name) == T_STRING) {
@@ -4390,10 +4392,12 @@ cb_generate_bucket_settings(VALUE bucket, couchbase::core::management::cluster::
4390
4392
throw ruby_exception (rb_eArgError, rb_sprintf (" bucket name must be a String, given %+" PRIsVALUE, name));
4391
4393
}
4392
4394
4393
- if (VALUE quota = rb_hash_aref (bucket, rb_id2sym (rb_intern (" ram_quota_mb" ))); TYPE (quota) == T_FIXNUM) {
4394
- entry.ram_quota_mb = FIX2ULONG (quota);
4395
- } else {
4396
- throw ruby_exception (rb_eArgError, rb_sprintf (" bucket RAM quota must be an Integer, given %+" PRIsVALUE, quota));
4395
+ if (VALUE quota = rb_hash_aref (bucket, rb_id2sym (rb_intern (" ram_quota_mb" ))); !NIL_P (quota)) {
4396
+ if (TYPE (quota) == T_FIXNUM) {
4397
+ entry.ram_quota_mb = FIX2ULONG (quota);
4398
+ } else {
4399
+ throw ruby_exception (rb_eArgError, rb_sprintf (" bucket RAM quota must be an Integer, given %+" PRIsVALUE, quota));
4400
+ }
4397
4401
}
4398
4402
4399
4403
if (VALUE expiry = rb_hash_aref (bucket, rb_id2sym (rb_intern (" max_expiry" ))); !NIL_P (expiry)) {
@@ -4679,7 +4683,9 @@ cb_extract_bucket_settings(const couchbase::core::management::cluster::bucket_se
4679
4683
rb_hash_aset (bucket, rb_id2sym (rb_intern (" name" )), cb_str_new (entry.name ));
4680
4684
rb_hash_aset (bucket, rb_id2sym (rb_intern (" uuid" )), cb_str_new (entry.uuid ));
4681
4685
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 ));
4686
+ if (entry.max_expiry .has_value ()) {
4687
+ rb_hash_aset (bucket, rb_id2sym (rb_intern (" max_expiry" )), ULONG2NUM (entry.max_expiry .value ()));
4688
+ }
4683
4689
switch (entry.compression_mode ) {
4684
4690
case couchbase::core::management::cluster::bucket_compression::off:
4685
4691
rb_hash_aset (bucket, rb_id2sym (rb_intern (" compression_mode" )), rb_id2sym (rb_intern (" off" )));
@@ -4694,9 +4700,15 @@ cb_extract_bucket_settings(const couchbase::core::management::cluster::bucket_se
4694
4700
rb_hash_aset (bucket, rb_id2sym (rb_intern (" compression_mode" )), Qnil);
4695
4701
break ;
4696
4702
}
4697
- rb_hash_aset (bucket, rb_id2sym (rb_intern (" num_replicas" )), ULONG2NUM (entry.num_replicas ));
4698
- rb_hash_aset (bucket, rb_id2sym (rb_intern (" replica_indexes" )), entry.replica_indexes ? Qtrue : Qfalse);
4699
- rb_hash_aset (bucket, rb_id2sym (rb_intern (" flush_enabled" )), entry.flush_enabled ? Qtrue : Qfalse);
4703
+ if (entry.num_replicas .has_value ()) {
4704
+ rb_hash_aset (bucket, rb_id2sym (rb_intern (" num_replicas" )), ULONG2NUM (entry.num_replicas .value ()));
4705
+ }
4706
+ if (entry.replica_indexes .has_value ()) {
4707
+ rb_hash_aset (bucket, rb_id2sym (rb_intern (" replica_indexes" )), entry.replica_indexes .value () ? Qtrue : Qfalse);
4708
+ }
4709
+ if (entry.flush_enabled .has_value ()) {
4710
+ rb_hash_aset (bucket, rb_id2sym (rb_intern (" flush_enabled" )), entry.flush_enabled .value () ? Qtrue : Qfalse);
4711
+ }
4700
4712
switch (entry.eviction_policy ) {
4701
4713
case couchbase::core::management::cluster::bucket_eviction_policy::full:
4702
4714
rb_hash_aset (bucket, rb_id2sym (rb_intern (" eviction_policy" )), rb_id2sym (rb_intern (" full" )));
@@ -4750,8 +4762,12 @@ cb_extract_bucket_settings(const couchbase::core::management::cluster::bucket_se
4750
4762
rb_id2sym (rb_intern (" history_retention_collection_default" )),
4751
4763
entry.history_retention_collection_default .value () ? Qtrue : Qfalse);
4752
4764
}
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 ));
4765
+ if (entry.history_retention_bytes .has_value ()) {
4766
+ rb_hash_aset (bucket, rb_id2sym (rb_intern (" history_retention_bytes" )), ULONG2NUM (entry.history_retention_bytes .value ()));
4767
+ }
4768
+ if (entry.history_retention_duration .has_value ()) {
4769
+ rb_hash_aset (bucket, rb_id2sym (rb_intern (" history_retention_duration" )), ULONG2NUM (entry.history_retention_duration .value ()));
4770
+ }
4755
4771
4756
4772
VALUE capabilities = rb_ary_new_capa (static_cast <long >(entry.capabilities .size ()));
4757
4773
for (const auto & capa : entry.capabilities ) {
0 commit comments