Skip to content
Snippets Groups Projects
Verified Commit 2bf47c8d authored by Timm Fitschen's avatar Timm Fitschen
Browse files

Merge branch 'dev' into f-doc-query

parents 33739032 4a7d87df
No related branches found
No related tags found
2 merge requests!96DOC: Added CITATION.cff to the list of files in the release guide where the...,!89DOC: enhance query documentation
Pipeline #35718 passed
......@@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Removed ###
### Fixed ###
- [#203](https://gitlab.com/caosdb/caosdb-server/-/issues/203)
* Denying a role permission has no effect
[#196](https://gitlab.com/caosdb/caosdb-server/-/issues/196). See security
......
......@@ -133,6 +133,7 @@ entity_filter returns [EntityFilterInterface filter]
(
(
LPAREN WHITE_SPACE?
(HAS_A (PROPERTY)?)?
(
filter_expression {$filter = $filter_expression.efi;}
| conjunction {$filter = $conjunction.c;}
......@@ -433,6 +434,7 @@ conjunction returns [Conjunction c]
f1 = filter_expression {$c.add($f1.efi);}
|
LPAREN WHITE_SPACE?
(HAS_A (PROPERTY)?)?
(
f4 = filter_expression {$c.add($f4.efi);}
| disjunction {$c.add($disjunction.d);}
......@@ -473,6 +475,7 @@ disjunction returns [Disjunction d]
f1 = filter_expression {$d.add($f1.efi);}
|
LPAREN WHITE_SPACE?
(HAS_A (PROPERTY)?)?
(
f4 = filter_expression {$d.add($f4.efi);}
| conjunction {$d.add($conjunction.c);}
......
......@@ -281,6 +281,8 @@ public class TestCQL {
// quotation marks gone rogue
String quotation1 =
"FIND ENTITY WHICH HAS A PROPERTY LIKE '*with double*' AND A PROPERTY LIKE '*and single*' AND A PROPERTY LIKE '*what\\'s wrong?*' AND A PROPERTY LIKE '*\\'*' AND A PROPERTY LIKE '*nothin\\'*' AND A PROPERTY LIKE '*\"\\'bla*'";
String issue203a = "FIND WHICH ( HAS pname )";
String issue203b = "FIND WHICH ( HAS pname1 AND REFERENCES pname2 )";
@Test
public void testQuery1()
......@@ -7013,4 +7015,37 @@ public class TestCQL {
assertEquals("POV(null,LIKE ,%nothin'%)", conj.getFilters().get(4).toString());
assertEquals("POV(null,LIKE ,%\"'bla%)", conj.getFilters().get(5).toString());
}
/**
* Test that brackets around 'has pname' do not cause filter to become subproperty filter.
*
* <p>https://gitlab.com/caosdb/caosdb-server/-/issues/203
*/
@Test
public void testIssue203() {
// setup 203a
CQLLexer lexer;
lexer = new CQLLexer(CharStreams.fromString(this.issue203a));
CommonTokenStream tokens = new CommonTokenStream(lexer);
CQLParser parser = new CQLParser(tokens);
CqContext sfq = parser.cq();
// here we test that the filter stays a POV and is not falsly interpreted
// as subproperty filter
assertTrue(sfq.filter instanceof POV);
// setup 203b (with conjunction)
lexer = new CQLLexer(CharStreams.fromString(this.issue203b));
tokens = new CommonTokenStream(lexer);
parser = new CQLParser(tokens);
sfq = parser.cq();
Conjunction conj = (Conjunction) sfq.filter;
// the outer filter should be conjuction
assertTrue(sfq.filter instanceof Conjunction);
// here we test that the filters stays a POV and is not falsly interpreted
// as subproperty filters
assertTrue(conj.getFilters().get(0) instanceof POV);
assertTrue(conj.getFilters().get(1) instanceof POV);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment