From e6f4cb908de9c08a14db87b73b412e46008b075c Mon Sep 17 00:00:00 2001 From: Jim Lake Date: Fri, 28 Nov 2025 17:10:42 +0000 Subject: [PATCH] allow set to include the full grammar --- pegjs/mysql.pegjs | 4 ++-- test/cmd.spec.js | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pegjs/mysql.pegjs b/pegjs/mysql.pegjs index fe436a79..41ddf025 100644 --- a/pegjs/mysql.pegjs +++ b/pegjs/mysql.pegjs @@ -4399,7 +4399,7 @@ assign_stmt_list } assign_stmt - = va:(var_decl / without_prefix_var_decl) __ s: (KW_ASSIGN / KW_ASSIGIN_EQUAL) __ e:proc_expr { + = va:(var_decl / without_prefix_var_decl) __ s: (KW_ASSIGN / KW_ASSIGIN_EQUAL) __ e:expr { return { type: 'assign', left: va, @@ -4409,7 +4409,7 @@ assign_stmt } select_assign_stmt - = va:(var_decl / without_prefix_var_decl) __ s:KW_ASSIGN __ e:proc_expr { + = va:(var_decl / without_prefix_var_decl) __ s:KW_ASSIGN __ e:expr { return { type: 'assign', left: va, diff --git a/test/cmd.spec.js b/test/cmd.spec.js index ee25307c..22528fe2 100644 --- a/test/cmd.spec.js +++ b/test/cmd.spec.js @@ -369,6 +369,11 @@ describe('Command SQL', () => { .to.equal(`SET @@${keyword}.id = 123 ; SET @@${keyword}.yy.xx = "abcd"`); }) }) + + it('should support set variable with cast', () => { + expect(getParsedSql('SET @myvar=CAST("123.1" AS DOUBLE)')) + .to.equal('SET @myvar = CAST("123.1" AS DOUBLE)'); + }) }) describe('unlock', () => {