Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

MergeActionClause object has wrong FirstTokenIndex value

Aperta
#118 0 commenti 5 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
sql

Direzione di ricerca

Inizia riproducendo l’istruzione MERGE fornita e individuando dove vengono assegnati gli indici dei token di MergeActionClause. Confronta le prime due clausole, quindi aggiungi un test di regressione che mostri che ogni MergeActionClause.FirstTokenIndex punta alla propria parola chiave WHEN; la correzione è completata quando i valori riportati riflettono quelle posizioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

ScriptDom version: 161.9142.1
Compatibility level: 150

After parsing a MERGE statement MergeActionClause instance has the same FirstTokenIndex as it's property - Action (for example, ValuesInsertSource instance); in case if there is a SearchCondition then the clause's FirstTokenIndex will equal to SearchCondition.FirstTokenIndex value. This seems to be inaccurate. MergeActionClause is the object containing Condition, SearchCondition and Action properties which makes me believe that the MergeActionClause instance is supposed to match the whole clause starting with WHEN keyword which occurs way earlier in a script than the merge action (or search condition).

Here is a sample script:

MERGE t WITH (HOLDLOCK) AS trg
USING (SELECT * FROM @src) AS src
ON trg.id = src.id
WHEN NOT MATCHED AND (1=1) THEN
    INSERT (title)
    VALUES (src.title)
WHEN NOT MATCHED BY SOURCE THEN
    DELETE
WHEN MATCHED THEN
    UPDATE SET
        title = src.title,
        lastmod = SYSDATETIME()
OUTPUT DELETED.title AS old_title, $action AS act
INTO @log(old_title, act);

for the first clause WHEN NOT MATCHED AND (1=1) THEN INSERT clause:

MergeActionClause.SearchCondition.FirstTokenIndex = 50
MergeActionClause.Action.FirstTokenIndex = 59
MergeActionClause.FirstTokenIndex = 50 (same as for SearchCondition)

Image

for the second clause WHEN NOT MATCHED BY SOURCE THEN DELETE without SearchCondition:

MergeActionClause.Action.FirstTokenIndex = 87
MergeActionClause.FirstTokenIndex = 87 (same as for Action)

Image

and this makes it hard to work with such clauses in code - the beginning of each WHEN has to be located manually by iterating tokens backwards.

MergeActionClause.FirstTokenIndex should always point to the WHEN keyword.


See also token-index related bug-reports: #90 , #91

Lingua principale
GAP
Stelle
277
Fork
43
Merge medio
6g 17h
PR unite (30g)
3

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/SqlScriptDOM

Tutte le issue di microsoft/SqlScriptDOM

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.