SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
[11.3.277 Pro] - FR: Always Add Delimiters

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
[11.3.277 Pro] - FR: Always Add Delimiters
Author Message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post [11.3.277 Pro] - FR: Always Add Delimiters Reply with quote
Currently, in MariaDB, MySQL and SQL Server, having the setting Auto Complete / Always Add Delimiters set to Always add brackets/apostrophes/double-quotes has no effect on declared variable names when autocompleting them in SQL Server or MariaDB.

That's actually a good thing in SQL Server because that one does not allow the identifiers of declared variables to be delimited (not to mention that having that mandatory @ in front of the name makes the declared variable identifier rather distinct to other identifiers.

However, that's not the case with MariaDB and MySQL, they are quite happy to see variable names delimited by apostrophes. Would you be so kind to explore the possibilities of expanding that auto-complete feature so that there could be an additional option in Auto Complete / Always Add Delimiters, that auto-delimits those pesky declared variable identifiers too, please?
Wed Sep 16, 2020 9:06 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7842

Post Reply with quote
May I ask for a short example of how you create variables, which I can attach to the enhancement request? I don't mean how you name them with delimiters or not, rather the use case scenario describing where the names come from. Are you using snippets to generate that code with variables?
Fri Sep 18, 2020 12:58 pm View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
Certainly. I use a snippet:
Code:

DECLARE `lv_|`;

When not using this snippet to declare them, I type everything manually, including the apostrophes. When using the declared variables I usually pick them from a popup and immediately trigger another snippet
Code:

`$CURRENT(param1, skip_parentheses)$`

that will quickly "fix" the variable name

It would be awesome if SA could recognize that after typing the DECLARE keyword the next word will most likely be a variable name and automatically add the delimiters. And let me go further. If the Code Formatting feature would somehow "autocomplete" the missing delimiters (kinda like the Refactoring / Qualify Object Names works for missing schema names), that would be absolutely mind-boggling (I could "repair" tons of code written years ago lacking the proper delimiters). But I guess that would require some pretty nasty heuristics. So even simply having the popup-selected variable names auto-delimited would be great.
Sun Sep 20, 2020 3:49 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7842

Post Reply with quote
I'm not completely sure I understand. What do you pick from a popup in the first place, column name?

Would the following work for you?

Create DEC macro that would have last char ass it trigger. As soon as you type 3 letters DEC, a column popup will appear.

Code:
DECLARE `lv_$COLUMNS$`;

Tue Sep 22, 2020 9:42 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
No, that won't work but because of other reasons. I've created three versions of the snippet.

Code:

DECLARE `lv_$COLUMNS$`;

Code:

DECLARE lv_$COLUMNS$;

Code:

"DECLARE lv_"$COLUMNS(types)$";"


Anyway, it will be easier to explain with a video. Check it here.

The first snippet duplicates the aposthropes (I have Auto Complete / Always Add Delimiters set to Always add apostrophes ``). It doesn't add the keyword DECLARE to each column and that's not a proper syntax for MariaDB. Also, when formatting the result of that will end up in adding another surplus apostrophe to the first variable, but I couldn't figure out why.

Removing the apostrophes from the snippet will add the apostrophes to the end result correctly but the generated code is not syntactically correct. In addition (or subtraction?), it does not add the types but again, that's another problem.

I've tried fixing that, the resulting last snippet was the closest I could come to it working properly for declaring variables for table columns. It still adds a surplus comma after each variable definition that has to be removed to be correct, but at least it does most of the work.

But that still is not the main reason for this post. Let's suppose the variables were declared properly as they were in the video you can watch here.

When picking the variable names from a popup (line 10), they are inserted into the code but they are not delimited. In the last line (line 13) I used a snippet triggered by `1
Code:

`$CURRENT(param1, skip_parentheses)$`

to quickly add the apostrophes to the last inserted variable without needing to move the cursor around. It's pretty fast, but it adds overhead and sometimes I forget to do it.
Wed Sep 23, 2020 2:21 am View user's profile Send private message
Lofeso
Guest





Post Reply with quote
Thank you for the advice of creating a DEC macro, it really solved my problem. Was kind of stuck on this issue for sometime while I was all day today in my Munich home here. No it works perfectly.


Last edited by Lofeso on Thu Oct 01, 2020 3:58 am; edited 1 time in total
Sat Sep 26, 2020 2:02 pm
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
Lofeso wrote:
Thank you for the advice of creating a DEC macro, it really solved my problem. Was kind of stuck on this issue for sometime while I was all day today in my Munich home. No it works perfectly.


What was that problem exactly?
Sun Sep 27, 2020 5:33 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7842

Post Reply with quote
Please ignore the previous post, most likely that was a spamming attempt partially blocked by the system. The user's IP matches known spamming host
https://www.stopforumspam.com/ipcheck/195.224.45.178 - based on characteristics it looks like a remotely controlled host/exploit
Sun Sep 27, 2020 9:17 am View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
Ohh, I see. I'm usually "wary" when answering new users with very few posts but this one seemed to be a "legitimate" one. Though Munich was definitely a red flag. Or at least an orange one.
Sun Sep 27, 2020 4:47 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7842

Post Reply with quote
This issue has been confirmed as unintentional side effect from other changes. We are going to provide some solution in the next maintenance release, likely using additional options at the snippet level, but not final engineering decision has been made yet on how to resolve that.
Wed Sep 30, 2020 12:35 pm View user's profile Send private message
gemisigo



Joined: 11 Mar 2010
Posts: 2102

Post Reply with quote
Any updates on this one?
Mon Jan 11, 2021 6:36 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.