Skip to content

Commit

Permalink
fix(frontend): accept all boolean literals for boolean config entry (#…
Browse files Browse the repository at this point in the history
…15485)

Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao authored Mar 7, 2024
1 parent 63a2859 commit 1a9e6e4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
9 changes: 9 additions & 0 deletions e2e_test/batch/config.slt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,12 @@ query T
show application_name;
----
slt

statement ok
set synchronize_seqscans to on;

statement ok
set synchronize_seqscans to f;

statement ok
set synchronize_seqscans to default;
2 changes: 1 addition & 1 deletion e2e_test/error_ui/simple/main.slt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ db error: ERROR: Failed to run the query
Caused by these errors (recent errors listed first):
1: Failed to get/set session config
2: Invalid value `maybe` for `rw_implicit_flush`
3: provided string was not `true` or `false`
3: Invalid bool


statement error
Expand Down
9 changes: 8 additions & 1 deletion src/common/proc_macro/src/session_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,21 @@ pub(crate) fn derive_config(input: DeriveInput) -> TokenStream {
quote! {}
};

// An easy way to check if the type is bool and use a different parse function.
let parse = if quote!(#ty).to_string() == "bool" {
quote!(risingwave_common::cast::str_to_bool)
} else {
quote!(<#ty as ::std::str::FromStr>::from_str)
};

struct_impl_set.push(quote! {
#[doc = #set_func_doc]
pub fn #set_func_name(
&mut self,
val: &str,
reporter: &mut impl ConfigReporter
) -> SessionConfigResult<()> {
let val_t = <#ty as ::std::str::FromStr>::from_str(val).map_err(|e| {
let val_t = #parse(val).map_err(|e| {
SessionConfigError::InvalidValue {
entry: #entry_name,
value: val.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion src/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#![feature(array_methods)]
#![feature(btree_cursors)]

#[cfg_attr(not(test), expect(unused_extern_crates))]
#[cfg_attr(not(test), allow(unused_extern_crates))]
extern crate self as risingwave_common;

#[macro_use]
Expand Down

0 comments on commit 1a9e6e4

Please sign in to comment.