@@ -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)) {
@@ -4699,8 +4703,12 @@ cb_extract_bucket_settings(const couchbase::core::management::cluster::bucket_se
4699
4703
if (const auto &val = entry.num_replicas ; val.has_value ()) {
4700
4704
rb_hash_aset (bucket, rb_id2sym (rb_intern (" num_replicas" )), ULONG2NUM (val.value ()));
4701
4705
}
4702
- rb_hash_aset (bucket, rb_id2sym (rb_intern (" replica_indexes" )), entry.replica_indexes ? Qtrue : Qfalse);
4703
- rb_hash_aset (bucket, rb_id2sym (rb_intern (" flush_enabled" )), entry.flush_enabled ? Qtrue : Qfalse);
4706
+ if (const auto &val = entry.replica_indexes ; val.has_value ()) {
4707
+ rb_hash_aset (bucket, rb_id2sym (rb_intern (" replica_indexes" )), val.value () ? Qtrue : Qfalse);
4708
+ }
4709
+ if (const auto &val = entry.flush_enabled ; val.has_value ()) {
4710
+ rb_hash_aset (bucket, rb_id2sym (rb_intern (" flush_enabled" )), val.value () ? Qtrue : Qfalse);
4711
+ }
4704
4712
switch (entry.eviction_policy ) {
4705
4713
case couchbase::core::management::cluster::bucket_eviction_policy::full:
4706
4714
rb_hash_aset (bucket, rb_id2sym (rb_intern (" eviction_policy" )), rb_id2sym (rb_intern (" full" )));
0 commit comments