SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
sql preprocessor and --#region

 
Reply to topic    SoftTree Technologies Forum Index » SQL Assistant View previous topic
View next topic
sql preprocessor and --#region
Author Message
13th



Joined: 12 Jan 2014
Posts: 27
Country: United Kingdom

Post sql preprocessor and --#region Reply with quote
when sql preprocessor is turned on
Quote:
--#region
doesn't save within altered procedure or function
Thu Oct 05, 2023 11:36 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
Could you please attach a screenshot demonstrating the issue? I'm not sure I understand.
Fri Oct 06, 2023 1:42 am View user's profile Send private message
13th



Joined: 12 Jan 2014
Posts: 27
Country: United Kingdom

Post Reply with quote
it's cannot be explained by screenshot

options>db options>sql server>sql preprocessor>active = yes
then
Code:
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
Code:
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
I think you are missing a space between -- and #.
Does adding space resolve your issue?
Fri Oct 06, 2023 8:30 am View user's profile Send private message
13th



Joined: 12 Jan 2014
Posts: 27
Country: United Kingdom

Post Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
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 View user's profile Send private message
13th



Joined: 12 Jan 2014
Posts: 27
Country: United Kingdom

Post Reply with quote
SysOp wrote:
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
Code:
--################
--#   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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
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 View user's profile Send private message
13th



Joined: 12 Jan 2014
Posts: 27
Country: United Kingdom

Post Reply with quote
SysOp wrote:
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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7849

Post Reply with quote
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 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.