File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/test/java/net/sf/jsqlparser/test/select Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1850,6 +1850,24 @@ public void testNotEqualsTo() throws JSQLParserException {
1850
1850
1851
1851
public void testJsonExpression () throws JSQLParserException {
1852
1852
assertSqlCanBeParsedAndDeparsed ("SELECT data->'images'->'thumbnail'->'url' AS thumb FROM instagram" );
1853
+ assertSqlCanBeParsedAndDeparsed ("SELECT * FROM sales WHERE sale->'items'->>'description' = 'milk'" );
1854
+ assertSqlCanBeParsedAndDeparsed ("SELECT * FROM sales WHERE sale->'items'->>'quantity' = 12::TEXT" );
1855
+ //assertSqlCanBeParsedAndDeparsed("SELECT * FROM sales WHERE CAST(sale->'items'->>'quantity' AS integer) = 2");
1856
+ assertSqlCanBeParsedAndDeparsed ("SELECT SUM(CAST(sale->'items'->>'quantity' AS integer)) AS total_quantity_sold FROM sales" );
1857
+ assertSqlCanBeParsedAndDeparsed ("SELECT sale->>'items' FROM sales" );
1858
+ assertSqlCanBeParsedAndDeparsed ("SELECT json_typeof(sale->'items'), json_typeof(sale->'items'->'quantity') FROM sales" );
1859
+
1860
+
1861
+ //The following staments can be parsed but not deparsed
1862
+ for (String statement : new String []{
1863
+ "SELECT doc->'site_name' FROM websites WHERE doc @> '{\" tags\" :[{\" term\" :\" paris\" }, {\" term\" :\" food\" }]}'" ,
1864
+ "SELECT * FROM sales where sale ->'items' @> '[{\" count\" :0}]'" ,
1865
+ "SELECT * FROM sales where sale ->'items' ? 'name'" ,
1866
+ "SELECT * FROM sales where sale ->'items' -# 'name'"
1867
+ }){
1868
+ Select select = (Select ) parserManager .parse (new StringReader (statement ));
1869
+ assertStatementCanBeDeparsedAs (select , statement , true );
1870
+ }
1853
1871
}
1854
1872
1855
1873
public void testSelectInto1 () throws JSQLParserException {
You can’t perform that action at this time.
0 commit comments