Skip to Main Content

SQLcl: MCP Server & SQL Prompt

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQLcl Project: project export Collapses Leading Comment Lines After "AS" AND SPACE in Package Specs/Bodies

Alexander Kluev6 days ago — edited 6 days ago

Hi Team,

I’ve identified another formatting issue in SQLcl Project that affects create package and create package body statements.

If there is a space after **AS**, and the package begins with either a block comment or one or more line comments (starting on the same line or the next line), project export collapses the first comment line up to the AS line.

It's important for me because:

  1. It's a delta from 25.3.0. - it interferes with my drift detection significantly; It affects 28 objects in my repository
  2. The result of formatting is very unexpected and I would even say inconsistent.

Here is a simple example:

Create these 4 small packages. Make sure you leave a space after “CREATE PACKAGE AS”:

create or replace package foo.block_comment as /*
this is a first line of block comment
*/
  gc_cont constant int := 1;
end;
/
create or replace package foo.block_comment1 as 
/* this is a first line of block comment
*/
  gc_cont constant int := 1;
end;
/
create or replace package foo.line_comment1 as 
  --  this is a first line of block comment
  -- second line 
  gc_cont constant int := 1;
end;
/
create or replace package foo.no_comment1 as 
gc_cont constant int := 1; 
end; 
/ 

Run Export:

project export -o block_comment,block_comment1,line_comment1,no_comment1

Examine resulting files; you should notice that in all cases except no_comment1, the first line of comment is collapsed into the same line as create package

create or replace package foo.block_comment as /* this is a first line of block comment 
*/ 
gc_cont constant int := 1; 
end; 
/ 


-- sqlcl_snapshot {"hash":"f3a98a99afe5c2c350ad6513e8e3164648f239a8","type":"PACKAGE_SPEC","name":"BLOCK_COMMENT","schemaName":"FOO","sxml":""}

create or replace package foo.block_comment1 as /* this is a first line of block comment 
*/ 
gc_cont constant int := 1; 
end; 
/ 


-- sqlcl_snapshot {"hash":"2172da2194c3b8de68477c1f78faf512511c91bf","type":"PACKAGE_SPEC","name":"BLOCK_COMMENT1","schemaName":"FOO","sxml":""}

create or replace package foo.line_comment1 as -- this is a first line of block comment 
-- second line 
gc_cont constant int := 1; 
end; 
/ 


-- sqlcl_snapshot {"hash":"88cedac039dd9930d2ce550ab0c62877704cdbeb","type":"PACKAGE_SPEC","name":"LINE_COMMENT1","schemaName":"FOO","sxml":""}

If you update the package and remove “ ” after “AS” the behavior will be as expected

Also, a package with no comment on the first line works the same way whether or not there is a space after “as” and the same way it's expected to work as works in 23.0:

create or replace package foo.no_comment1 as 
gc_cont constant int := 1; 
end; 
/ 


-- sqlcl_snapshot {"hash":"12279b1787cb6bec2b01afa8f3b2acb172093615","type":"PACKAGE_SPEC","name":"NO_COMMENT1","schemaName":"FOO","sxml":""}

Best,

Alex

Comments
Post Details
Added 6 days ago
0 comments
34 views