ScriptDom interprets ambiguously the next word right after transaction control statement
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
Comece reproduzindo os exemplos de BEGIN, SAVE, COMMIT e ROLLBACK com os níveis de compatibilidade 150 e 160 do ScriptDom. Revise como os nomes de transações e as instruções de uma palavra que os seguem são classificados e, em seguida, defina o comportamento esperado para casos como THROW e CONTINUE; a issue estará concluída quando a ambiguidade for resolvida ou um aviso for fornecido de forma consistente.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
- ScriptDom Version: 161.8910.0
- CompatibilityLevel used for parsing: 150, 160
Some keywords written right next to the transaction control statement are treated as transaction name and some as a separate command/next statement. This may lead to significant misunderstanding of what the code will actually do.
Statements:
- BEGIN TRAN
- SAVE TRAN
- COMMIT TRAN
- ROLLBACK TRAN
Examples of keywords/statements treated as valid identifier for transaction name:
- THROW
- RECEIVE
- SEND
Steps to Reproduce:
If you write BEGIN TRAN THROW - here THROW will be treated as a valid transaction name. However in BEGIN TRAN CONTINUE the CONTINUE will be treated as a separate command. BEGIN/COMMIT/ROLLBACK behave similarly - they can take modern keywords/commands as a valid tran name but "ignore" "oldschool" keywords/commands and treat them as a separate statement even if no statement terminator is present between them. SAVE TRAN unlikely mentioned statements requires transaction name to be provided and if the next word is parsed as an invalid tran identifier candidate the parsing fails with syntax error.
Examples of ambiguity:
COMMIT TRAN CONTINUE
COMMIT TRAN BREAK
COMMIT TRAN THROW -- tran name
COMMIT TRAN RECEIVE -- tran name
COMMIT TRAN SEND -- tran name
COMMIT TRAN RETURN
COMMIT TRAN COMMIT
COMMIT TRAN ROLLBACK
in all lines not marked with comment the last word is treated as a separate statement.
SAVE TRAN requires third word in statement and in all lines except marked with comment parser would say that syntax is broken:
The most ambiguous case to me is this one:
BEGIN TRY
BEGIN TRAN
SELECT 1 / 0
COMMIT TRAN
END TRY
BEGIN CATCH
ROLLBACK TRAN
THROW -- "Divide by zero" error will not be rethrown here
-- new error will be generated:
-- Cannot roll back THROW. No transaction or savepoint of that name was found
END CATCH
On ROLLBACK TRAN docs page it is said that transaction name must be a valid identifier, identifier is valid if it does not match any of reserved words and THROW is not listed there. On THROW docs page it is said that preceding statement must end with semicolon. Thus ROLLBACK TRAN THROW in the example above behaves expectedly speaking of the docs. But it is an error so easy to make and you need so much to remember to avoid it while coding.
It would be great if
- all one-word statements were included into reserved keywords (especially
THROW); maybe in future compatibility levels - SSDT/DacFx would show at least a warning in such cases and recommend to put semicolon before
THROWor choose another identifier for transaction name
As a workaround I'm developing another rule for our custom linter which would detect such suspicious cases.
(DacFx/SqlPackage/SSMS/Azure Data Studio)
- Linguagem predominante
- GAP
- Estrelas
- 278
- Forks
- 46
- Merge médio
- 9d 23h
- PRs com merge (30d)
- 2
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de microsoft/SqlScriptDOM
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
microsoft/SqlScriptDOM#228 ·
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
microsoft/SqlScriptDOM#183 ·
-
Add a Multiline option for CASE expressions (WHEN/THEN/ELSE on their own lines)Talvez já em andamento @trg-alasdair assumiu há 4 dias. Aberta
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 56/100
microsoft/SqlScriptDOM#226 · 1 reação ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 48/100
microsoft/SqlScriptDOM#225 ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 58/100
microsoft/SqlScriptDOM#224 ·
Todas as issues de microsoft/SqlScriptDOM
Issues semelhantes
-
vxc prints a debug line '[flat-codegen] emitted module via the flat path' on every compileTalvez já em andamento @YodHeVauHe assumiu hoje. Abertadevex good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
kmmbvnr/rank#196 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
SciML/ModelingToolkit.jl#5255 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
NVIDIA/cuda-quantum#5539 ·
Mantenedores costumam responder em até 1 dia
-
triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
NVIDIA/cuda-python#3015 · 2 comentários ·
Mantenedores costumam responder em até 1 dia