@@ -417,7 +417,7 @@ func (d *Document) parseCreate(s *Scanner, createCountInBatch int) (result Creat
417417 // point we copy the rest until the batch ends; *but* track dependencies
418418 // + some other details mentioned below
419419
420- firstAs := true
420+ // firstAs := true // See comment below on rowcount
421421
422422tailloop:
423423 for {
@@ -473,18 +473,41 @@ tailloop:
473473 case tt == ReservedWordToken && s .Token () == "as" :
474474 CopyToken (s , & result .Body )
475475 NextTokenCopyingWhitespace (s , & result .Body )
476- if firstAs {
477- // Add the `RoutineName` token as a convenience, so that we can refer to the procedure/function name
478- // from inside the procedure (for example, when logging)
479- if result .CreateType == "procedure" {
480- procNameToken := Unparsed {
481- Type : OtherToken ,
482- RawValue : fmt .Sprintf (templateRoutineName , strings .Trim (result .QuotedName .Value , "[]" )),
476+ /*
477+ TODO: Fix and re-enable
478+ This code add RoutineName for convenience. So:
479+
480+ create procedure [code@5420c0269aaf].Test as
481+ begin
482+ select 1
483+ end
484+ go
485+
486+ becomes:
487+
488+ create procedure [code@5420c0269aaf].Test as
489+ declare @RoutineName nvarchar(128)
490+ set @RoutineName = 'Test'
491+ begin
492+ select 1
493+ end
494+ go
495+
496+ However, for some very strange reason, @@rowcount is 1 with the first version,
497+ and it is 2 with the second version.
498+ if firstAs {
499+ // Add the `RoutineName` token as a convenience, so that we can refer to the procedure/function name
500+ // from inside the procedure (for example, when logging)
501+ if result.CreateType == "procedure" {
502+ procNameToken := Unparsed{
503+ Type: OtherToken,
504+ RawValue: fmt.Sprintf(templateRoutineName, strings.Trim(result.QuotedName.Value, "[]")),
505+ }
506+ result.Body = append(result.Body, procNameToken)
483507 }
484- result . Body = append ( result . Body , procNameToken )
508+ firstAs = false
485509 }
486- firstAs = false
487- }
510+ */
488511
489512 default :
490513 CopyToken (s , & result .Body )
0 commit comments