Database Schema Import was changed. All foreign keys of a table were imported in one rule. It causes a wrong result if foreign key columns have null values. Bugfix: Now one rule is generated for each foreign key. Please note that the bugfix only affects new database schema imports, but not old ontologies. So it's recommended to re-import database schemas for old ontologies.
Example
Tables t1, t2, t3.
t1
ID |
NAME |
|---|---|
1 |
a |
2 |
b |
t2
ID1 |
ID2 |
NAME |
|---|---|---|
3 |
33 |
c |
4 |
44 |
d |
t3
ID |
t1ID |
t2ID1 |
t2ID2 |
COL |
|---|---|---|---|---|
555 |
1 |
4 |
44 |
w |
777 |
2 |
null |
null |
q |
Table t3 has the following foreign keys: t3 (t1ID) references t1 column ID and t3 (t2ID1, t2ID2) references t2(ID1, ID2).
Generated Foreign Keys Mapping Rule
Before the bugfix:
c(T3,?VAR1)[FK_T3_T1->c(T1,?VAR2), FK_T3_T2->c(T2,?VAR3, ?VAR4)] :- _dbaccessuser("T3", f("ID", ?VAR1, "T1ID", ?VAR2, "T2ID1", ?VAR3, "T2ID2", ?VAR4),"conndatasource").
After the bugfix:
c(T3,?VAR1)[FK_T3_T1->c(T1,?VAR2)] :- _dbaccessuser("T3", f("ID", ?VAR1, "T1ID", ?VAR2),"conndatasource").
c(T3,?VAR1)[FK_T3_T2->c(T2,?VAR2, ?VAR3)] :- _dbaccessuser("T3", f("ID", ?VAR1, "T2ID1", ?VAR2, "T2ID2", ?VAR3),"conndatasource").
Query:
@{options[outorder(?T31_T3_COL,?T31_T3_T1ID,?T31_T3_ID)]} ?- ?T31:T3[T3_T1ID->?T31_T3_T1ID,T3_ID->?T31_T3_ID,T3_COL->?T31_T3_COL,FK_T3_T1->?T11] and ?T11:T1.
Result
Before the bugfix:
"w" 1 555
After the bugfix:
"w" 1 555
"q" 2 777