Author |
Message |
13th
Joined: 12 Jan 2014 Posts: 27 Country: United Kingdom |
|
sql preprocessor and --#region |
|
when sql preprocessor is turned on
 |
 |
--#region |
doesn't save within altered procedure or function
|
|
Thu Oct 05, 2023 11:36 pm |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Could you please attach a screenshot demonstrating the issue? I'm not sure I understand.
|
|
Fri Oct 06, 2023 1:42 am |
|
 |
13th
Joined: 12 Jan 2014 Posts: 27 Country: United Kingdom |
|
|
|
it's cannot be explained by screenshot
options>db options>sql server>sql preprocessor>active = yes
then
 |
 |
create procedure test as
--#region select
select 1
--#endregion |
then open that proc to edit
you'll see no "--#" comments.. because sql preprocessor using some hints of "--#" type like "--#define"
options>db options>sql server>sql preprocessor>active = no
then
 |
 |
alter procedure test as
--#region select
select 1
--#endregion |
then open that proc to edit - there will be --#region
seems like sql preprocessor doesn't send all "--#" comands to server, but --#region and --#endregion are not sql preprocessor hints
|
|
Fri Oct 06, 2023 6:32 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I think you are missing a space between -- and #.
Does adding space resolve your issue?
|
|
Fri Oct 06, 2023 8:30 am |
|
 |
13th
Joined: 12 Jan 2014 Posts: 27 Country: United Kingdom |
|
|
|
many procedures and functions have already been written with regions declared without a space, if I'll open any of them for editing with sql preprocessor enabled and forget to add spaces, regions will be lost
also SSMSBost tool that using some of team supports --#region (no space)
i think any --# comment that is not sql preprocessor hint logically should be sended to server as is but not deleted as now
|
|
Fri Oct 06, 2023 11:52 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Regions and other SQL Preprocessor directives are SQL Assistant's features, not SQL Server features. The instructions are executed by SQL Assistant, the database doesn't know anything about conditional code execution, code folding, etc... for the database, these are regular line comments starting with --.
|
|
Fri Oct 06, 2023 2:08 pm |
|
 |
13th
Joined: 12 Jan 2014 Posts: 27 Country: United Kingdom |
|
|
|
 |
 |
Regions and other SQL Preprocessor directives are SQL Assistant's features, not SQL Server features. The instructions are executed by SQL Assistant, the database doesn't know anything about conditional code execution, code folding, etc... for the database, these are regular line comments starting with --. |
You write obvious things, but I don’t understand what you want to say.
Do you mean that comments like
 |
 |
--################
--# comments #
--################ |
for some reason should not be sent to the server (to store within procedure text) because sql preprocessor is enabled ?
Someone created a procedure and commented it in this way, then I opened it for modification, sent it to the server and his comments disappeared - do you think this is correct?
sql preprocessor should process ONLY hints for sql preprocessor
|
|
Sat Oct 07, 2023 2:46 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Unfortunate such comments are incompatible with the SQL Preprocessor feature. You can turn that feature off, and it won't interfere. It shouldn't affect though collapsable regions feature -- #region.
One other idea, if you find it feasible, you can use Advanced Text Processor feature to reformat such comments and convert them from --# to something like --*#
|
|
Sat Oct 07, 2023 9:55 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Just in case, SQL Preprocessor can be turned on and off here Options -> DB Options -> SQL Server -> SQL Preprocessor -> Active
Please note it's database type specific, if you work with different databases and you want to turn it on or off for them too, repeat for each database type.
|
|
Sat Oct 07, 2023 10:58 am |
|
 |
13th
Joined: 12 Jan 2014 Posts: 27 Country: United Kingdom |
|
|
|
 |
 |
Unfortunate such comments are incompatible with the SQL Preprocessor feature. You can turn that feature off, and it won't interfere. It shouldn't affect though collapsable regions feature -- #region. |
i have started topic with that
such comments are incompatible due to an error that can be corrected by processing only specific commands, but it seems you do not want to admit it
|
|
Sun Oct 08, 2023 7:18 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
Well, what I can say, it's not an error, it's by design. "-- #" are SQL Prepocessor directives, they are like preporocessor language overlaying the SQL code. Invalid or unrecognized directives may lead to wrong code interpretation. We don't currently support ignoring unrecognized directives, we remove them from the executed code. Perhaps one of the solutions is to add an additional menu or hot key to enable "as is" code execution without engaging SQL Prepropcessor when it's active. I can submit an enhancement request on your behave if you want it.
|
|
Sun Oct 08, 2023 10:30 am |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
 |
 |
Well, what I can say, it's not an error, it's by design. "-- #" are SQL Prepocessor directives, they are like preporocessor language overlaying the SQL code. Invalid or unrecognized directives may lead to wrong code interpretation. We don't currently support ignoring unrecognized directives, we remove them from the executed code. Perhaps one of the solutions is to add an additional menu or hot key to enable "as is" code execution without engaging SQL Prepropcessor when it's active. I can submit an enhancement request on your behave if you want it. |
Is there any progress on this matter? The issue is that two features in SA clash with each other. I understand it is much easier to remove directives not recognized by one feature (preprocessor), but when that removal maims the other feature (code folding with #region) then that causes problems. To make it worse, disabling one feature (preprocessor) does not solve that problem, the #region comments are still removed from the executed code.
|
|
Mon Jun 03, 2024 3:26 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
I failed to find a ticket that matches exactly what has been discussed in this message thread. I also tested the alpha version 13, and it doesn't appear to remove #region related code directives.
|
|
Mon Jun 03, 2024 11:22 pm |
|
 |
gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
|
|
Do you have an ETA for v13?
|
|
Mon Jun 10, 2024 3:08 am |
|
 |
SysOp
Site Admin
Joined: 26 Nov 2006 Posts: 7948
|
|
|
|
We're aiming to get beta released by the end of this month, the date is yet to be confirmed
|
|
Mon Jun 10, 2024 5:14 pm |
|
 |
|