From 6601393bb039e9f6dfe452be7e43f7f26113b46a Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Thu, 23 Jun 2022 11:45:44 +0200
Subject: [PATCH] Add tests for
 https://gitlab.com/caosdb/caosdb-server/-/issues/145

---
 tests/test_issues_server.py | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/tests/test_issues_server.py b/tests/test_issues_server.py
index 76f8d70..47b57da 100644
--- a/tests/test_issues_server.py
+++ b/tests/test_issues_server.py
@@ -848,3 +848,34 @@ def test_141():
     # switch back to admin user
     db.configure_connection()
     assert db.execute_query("FIND TestRT", unique=True).description == "Desc2"
+
+
+def test_145():
+    """Searching for large numbers results in wrong results if integer values
+    are used.
+
+    https://gitlab.com/caosdb/caosdb-server/-/issues/145
+    """
+    db.Property("TestProp", datatype=db.TEXT).insert()
+    db.Property("TestPropInt", datatype=db.INTEGER).add_parent("TestProp").insert()
+    db.Property("TestPropDouble", datatype=db.DOUBLE).add_parent("TestProp").insert()
+
+    db.RecordType("TestRT").insert()
+    rec1 = db.Record("TestRec1").add_parent("TestRT").add_property("TestPropInt", 1_000_000_000).insert()
+    assert rec1.get_property("TestPropInt").value == 1_000_000_000
+    assert isinstance(rec1.get_property("TestPropInt").value, int)
+    rec2 = db.Record("TestRec2").add_parent("TestRT").add_property("TestPropDouble", 20_000_000_000).insert()
+    assert rec2.get_property("TestPropDouble").value == 20_000_000_000
+    assert isinstance(rec2.get_property("TestPropDouble").value, float)
+
+    assert db.execute_query("FIND TestRT WITH TestProp = 1000000000", unique=True).id == rec1.id
+    assert db.execute_query("FIND TestRT WITH TestProp = 1000000000.0", unique=True).id == rec1.id
+
+    assert db.execute_query("FIND TestRT WITH TestProp > 1000000000", unique=True).id == rec2.id
+    assert db.execute_query("FIND TestRT WITH TestProp > 1000000000.0", unique=True).id == rec2.id
+
+    assert db.execute_query("FIND TestRT WITH TestProp = 20000000000", unique=True).id == rec2.id
+    assert db.execute_query("FIND TestRT WITH TestProp = 20000000000.0", unique=True).id == rec2.id
+
+    assert db.execute_query("FIND TestRT WITH TestProp < 20000000000", unique=True).id == rec1.id
+    assert db.execute_query("FIND TestRT WITH TestProp < 20000000000.0", unique=True).id == rec1.id
-- 
GitLab