gemisigo
Joined: 11 Mar 2010 Posts: 2165
|
|
[13.0.56 Pro] - Formatting issues |
|
I have a short piece of code:
 |
 |
CREATE INDEX [ix_forg_tetel_250415_1614] ON [EN_DATA].[dbo].[Forg_tetel] ([Datum] ASC, [FeladatTipusId] ASC, [Jarat] ASC, [DiszpState] ASC) INCLUDE ([DesignedState], [Erkezes], [ErkLS], [FeladatId], [Gepkocsi], [GkVez], [IndLS], [IranyitoHely], [IrIndLS], [JaratDatum], [JaratErkezes], [JaratErkLS], [JaratIndLS], [JaratSzam], [masodresz_jarat]);
|
and two formatting rules for CREATE INDEX statements, and neither works as expected. The one in my T-SQL Compress ruleset is this:
 |
 |
CREATE ... INDEX ...
ON ... (..., ...)
INCLUDE (..., ...);
|
When applied to the code above, I'd expect the result to be:
 |
 |
CREATE INDEX [ix_forg_tetel_250415_1614]
ON [EN_DATA].[dbo].[Forg_tetel] ([Datum] ASC, [FeladatTipusId] ASC, [Jarat] ASC, [DiszpState] ASC)
INCLUDE ([DesignedState], [Erkezes], [ErkLS], [FeladatId], [Gepkocsi], [GkVez], [IndLS], [IranyitoHely], [IrIndLS], [JaratDatum], [JaratErkezes], [JaratErkLS], [JaratIndLS], [JaratSzam], [masodresz_jarat]);
|
Instead, I get this:
 |
 |
CREATE INDEX [ix_forg_tetel_250415_1614]
ON [EN_DATA].[dbo].[Forg_tetel] ([Datum] ASC, [FeladatTipusId] ASC, [Jarat] ASC, [DiszpState] ASC)
INCLUDE (
[DesignedState]
,[Erkezes]
,[ErkLS]
,[FeladatId]
,[Gepkocsi]
,[GkVez]
,[IndLS]
,[IranyitoHely]
,[IrIndLS]
,[JaratDatum]
,[JaratErkezes]
,[JaratErkLS]
,[JaratIndLS]
,[JaratSzam]
,[masodresz_jarat]
);
|
I guess this must be because my Line Length for DDL Code Wrapping was set to something that the INCLUDE line would go beyond (when I increased it to 280, it no longer broke it into one-line-per-column). But even in that case I'd expect it to try and populate the line like this:
 |
 |
CREATE INDEX [ix_forg_tetel_250415_1614]
ON [EN_DATA].[dbo].[Forg_tetel] ([Datum] ASC, [FeladatTipusId] ASC, [Jarat] ASC, [DiszpState] ASC)
INCLUDE ([DesignedState], [Erkezes], [ErkLS], [FeladatId], [Gepkocsi], [GkVez], [IndLS], [IranyitoHely], [IrIndLS],
[JaratDatum], [JaratErkezes], [JaratErkLS], [JaratIndLS], [JaratSzam], [masodresz_jarat]);
|
or something similar.
The other rule is this:
 |
 |
CREATE ... INDEX ...
ON ... ( ...
,...)
INCLUDE ( ...
,...)
WHERE ...
AND ...;
|
Applying this one has catastrophic consequences. The resulting code is ruined:
 |
 |
CREATE INDEX [ix_forg_tetel_250415_1614]
ON [EN_DATA].[dbo].[Forg_tetel] ( [Datum] ASC
( ,[FeladatTipusId] ASC
( ,[Jarat] ASC
( ,[DiszpState] ASC)
INCLUDE ( [DesignedState]
,[Erkezes]
,[ErkLS]
,[FeladatId]
,[Gepkocsi]
,[GkVez]
,[IndLS]
,[IranyitoHely]
,[IrIndLS]
,[JaratDatum]
,[JaratErkezes]
,[JaratErkLS]
,[JaratIndLS]
,[JaratSzam]
,[masodresz_jarat]);
|
It inserts unwanted opening parentheses into the code.
|
|