From e25b7b7f89ed5575167ed73e9179d8879d201c59 Mon Sep 17 00:00:00 2001
From: Daniel <daniel@harvey>
Date: Thu, 26 Nov 2020 17:26:09 +0100
Subject: [PATCH] ENH: New test for issue mysqlbackend#24.

---
 tests/test_issues_mysqlbackend.py | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/tests/test_issues_mysqlbackend.py b/tests/test_issues_mysqlbackend.py
index 64de2f2..0638b83 100644
--- a/tests/test_issues_mysqlbackend.py
+++ b/tests/test_issues_mysqlbackend.py
@@ -87,3 +87,33 @@ def test_issue_21():
     cont.insert()
 
     rec.delete()
+
+
+def test_issue_24():
+    """query ignores ID: FIND MusicalInstrument which is referenced by Analysis with ID=124 """
+    cont = db.Container()
+    A = db.RecordType(name="TypeA")
+    B = db.RecordType(name="TypeB")
+    prop = db.Property(name="prop_ba", datatype=db.REFERENCE)
+
+
+    # Referenced Records
+    a1 = db.Record().add_parent(A)
+    a2 = db.Record().add_parent(A)
+
+    # Referencing Records
+    b1 = db.Record().add_parent(B).add_property(prop, value=a1)
+    b2 = db.Record().add_parent(B).add_property(prop, value=a2)
+
+    cont.extend([A, B, prop, a1, a2, b1, b2])
+    cont.insert()
+
+    id_b1 = b1.id
+    query = "FIND TypeA WHICH IS REFERENCED BY TypeB WITH ID={}".format(id_b1)
+    print(query)
+    result = db.execute_query(query)
+    print(result)
+    assert len(result) == 1
+    print(result[0])
+    print(a1)
+    assert result[0].id == a1.id
-- 
GitLab