Skip to content

Commit faea45d

Browse files
Merge pull request #45 from Trivadis/bugfix/issue-44-hint-in-merge
Bugfix/issue 44 hint in merge
2 parents 17f009f + 325ca65 commit faea45d

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/main/java/com/trivadis/tvdcc/validators/Hint.xtend

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ class Hint extends PLSQLValidator implements PLSQLCopValidator {
256256
def private dispatch getTableReference(MergeStatement stmt) {
257257
val result = new ArrayList<Pair<String, String>>
258258
result.add(new Pair(stmt.intoClause?.table?.value, stmt.intoClause?.alias?.value))
259+
result.add(new Pair(stmt.usingClause?.table?.value, stmt.usingClause?.alias?.value))
259260
return result
260261
}
261262

src/test/java/com/trivadis/tvdcc/validators/tests/HintTest.xtend

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,5 +430,29 @@ class HintTest extends AbstractValidatorTest {
430430
val issues = stmt.issues
431431
Assert.assertEquals(0, issues.size)
432432
}
433+
434+
// -- issue 44 https://github.com/Trivadis/plsql-cop-validators/issues/44
435+
436+
@Test
437+
def void falsePositiveForHintsReferringTableAliasInUsingClauseOfMerge() {
438+
val stmt = '''
439+
merge /*+ use_hash (d s) */ into bonuses d
440+
using (select employee_id, salary, department_id
441+
from employees
442+
where department_id = 80) s
443+
on (d.employee_id = s.employee_id)
444+
when matched then
445+
update
446+
set d.bonus = d.bonus + s.salary *.01
447+
delete
448+
where (s.salary > 8000)
449+
when not matched then
450+
insert (d.employee_id, d.bonus)
451+
values (s.employee_id, s.salary *.01)
452+
where (s.salary <= 8000);
453+
'''
454+
val issues = stmt.issues
455+
Assert.assertEquals(0, issues.size)
456+
}
433457

434458
}

0 commit comments

Comments
 (0)