Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

MergeActionClause object has wrong FirstTokenIndex value

オープン
#118 コメント 0 件 リアクション 5 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
sql

調査の方向性

まず、提供された MERGE 文を再現し、MergeActionClause のトークンインデックスがどこで割り当てられているかを特定します。最初の 2 つの句を比較し、各 MergeActionClause.FirstTokenIndex がそれぞれの WHEN キーワードを指していることを示す回帰テストを追加します。報告された値がそれらの位置を反映すれば修正は完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
GAP
スター
277
フォーク
43
平均マージ
6日 17時間
マージ済み PR(30日)
3

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/SqlScriptDOM のほかの issue

microsoft/SqlScriptDOM の issue をすべて見る

似ている issue

Compilers の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。