diff --git a/CHANGELOG.md b/CHANGELOG.md index e4288aa79c9d90de1489bff48469e33366c7b7bd..998561fab055e9c317d19148b47e69f015ab6765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Tests for [caosdb-server#62](https://gitlab.com/caosdb/caosdb-server/-/issues/62) in caosdb-server-project, i.e., renaming of a RecordType that should be reflected in properties with that RT as datatype. +- Test for [#39](https://gitlab.com/caosdb/caosdb-server/-/issues/39) + in caosdb server which checks if quoted datetimes in queries are + evaluated correctly. ### Changed (for changes in existing functionality) diff --git a/tests/test_issues_server.py b/tests/test_issues_server.py index 2bc35a4eaed3ae883a2a416cfa41730574b7cb12..2f4b5c524a0b96a48417fb67cd5acac1416411fe 100644 --- a/tests/test_issues_server.py +++ b/tests/test_issues_server.py @@ -25,13 +25,13 @@ """Tests for issues on gitlab.com, project caosdb-server.""" import caosdb as db -from caosdb.exceptions import EntityError +from caosdb.exceptions import EntityError, TransactionError import pytest def setup_module(): try: - db.execute_query("FIND ENTITY WITH ID > 100").delete() + db.execute_query("FIND ENTITY WITH ID > 99").delete() except Exception as delete_exc: print(delete_exc) @@ -48,6 +48,27 @@ def teardown(): # ########################### Issue tests start here ##################### + +def test_issue_39(): + """Query Language Bug - quotes around year + + Test for https://gitlab.com/caosdb/caosdb-server/-/issues/39 + """ + date_str = "2020-01-01" + prop_name = "Test_Date" + db.Property(name=prop_name, datatype=db.DATETIME).insert() + db.RecordType(name="Test_Type").add_property(name=prop_name).insert() + db.Record(name="Test_Record").add_parent(name="Test_Type").add_property( + name=prop_name, value=date_str).insert() + # Quotes around years should work in the query + ent = db.execute_query("FIND entity WITH A Test_Date IN \"2020\"", + unique=True) + assert ent.get_property(prop_name).value == date_str + # This should raise a transaction error + with pytest.raises(TransactionError): + db.execute_query("FIND entity WITH A Test_Date IN \"abcd\"") + + @pytest.mark.xfail(reason="to be fixed in server repo") def test_issue_62(): """datatype is not changed when recordtype name changes