SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[11.5.362 Pro] - $CURRENT(...)$ issues on MariaDB

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[11.5.362 Pro] - $CURRENT(...)$ issues on MariaDB
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2100

Post [11.5.362 Pro] - $CURRENT(...)$ issues on MariaDB Reply with quote
I've got a snippet with the following code:
Code:

`$CURRENT(param1, names_only, skip_parentheses)$`


It fails when it comes to delimited user-defined variables.
Applying that snippet to a variable
Code:
@user_defined_variable

makes it become
Code:
`@user_defined_variable`

instead of
Code:
@`user_defined_variable`


It seems that the $CURRENT(...)$ macro considers the '@' as part of the name, which it isn't. It's just a marker that makes that name a user-defined variable (https://mariadb.com/kb/en/user-defined-variables/).
Sat Feb 06, 2021 2:16 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7833

Post Reply with quote
$CURRENT$ macro isn't database aware. It 's kind of generic text processing macro. Depending on its parameters, it can return current word, current text surrounded by qualifiers like ` ` or [ ] or " " if found around the current word, current selection, or the entire line.

For this kind of usage, you would need a more complex macro like the following

Code:
$$
SELECT CONCAT(CASE WHEN '$CURRENT(param1, names_only, skip_parentheses)$' LIKE '@%'
   THEN REPLACE('$CURRENT(param1, names_only, skip_parentheses)$', '@', '@`')
   ELSE '`$CURRENT(param1, names_only, skip_parentheses)$' END, '`')
$$

Sun Feb 07, 2021 2:25 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2100

Post Reply with quote
I didn't know it wasn't database aware. The example you provided will work in that simple case but if I had to switch every occurrence of the $CURRENT()$ macro that might meet delimited user-defined variable in MariaDB, that would create a snippet maintenance nightmare.

Though it would work if user-defined macros or nested snippets were possible. But I guess that would be extremely difficult to implement. You don't happen to have something similar planned on your roadmap, do you?
Sun Feb 07, 2021 7:31 am View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.