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
Signed-off-by: Bugen Zhao <[email protected]>
  • Loading branch information
BugenZhao committed Mar 6, 2024
1 parent 4cba127 commit 2cb7481
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
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;
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

0 comments on commit 2cb7481

Please sign in to comment.