1313import javaxt .json .*;
1414import javaxt .utils .Console ;
1515
16- import net .sf .jsqlparser .expression .Expression ;
1716import net .sf .jsqlparser .parser .*;
1817import net .sf .jsqlparser .statement .select .*;
1918import net .sf .jsqlparser .statement .Statement ;
@@ -192,43 +191,7 @@ else if (statement instanceof Select){
192191
193192
194193 //Check whether the select statement has illegal or unsupported functions
195- PlainSelect plainSelect = (PlainSelect ) select .getSelectBody ();
196- Iterator <SelectItem > it = plainSelect .getSelectItems ().iterator ();
197- while (it .hasNext ()){
198- SelectItem selectItem = it .next ();
199-
200- String functionName = null ;
201- if (selectItem instanceof SelectExpressionItem ){
202- SelectExpressionItem si = (SelectExpressionItem ) selectItem ;
203- Expression expression = si .getExpression ();
204-
205- try {
206- net .sf .jsqlparser .expression .Function f = (net .sf .jsqlparser .expression .Function ) expression ;
207- functionName = f .getName ().toUpperCase ();
208-
209- }
210- catch (Exception e ){
211- try {
212- SubSelect ss = (SubSelect ) expression ;
213- functionName = "SELECT" ;
214- }
215- catch (Exception ex ){
216- }
217- }
218- }
219- else if (selectItem instanceof AllColumns ){}
220- else if (selectItem instanceof AllTableColumns ){}
221- else {
222- throw new IllegalArgumentException ("Unsupported select expression" );
223- }
224-
225-
226- if (functionName !=null ){
227- if (functionName .equals ("COUNT" )){
228- //throw new IllegalArgumentException(functionName + " statements are not currently supported");
229- }
230- }
231- }
194+ checkSelect ((PlainSelect ) select .getSelectBody ());
232195
233196
234197
@@ -295,6 +258,15 @@ else if (selectItem instanceof AllTableColumns){}
295258 }
296259
297260
261+ //**************************************************************************
262+ //** checkSelect
263+ //**************************************************************************
264+ /** Used to check whether the select statement has illegal or unsupported
265+ * functions
266+ */
267+ protected void checkSelect (PlainSelect plainSelect ){}
268+
269+
298270 //**************************************************************************
299271 //** Writer
300272 //**************************************************************************
@@ -662,18 +634,16 @@ private Integer getPid(String key, Connection conn) throws SQLException {
662634 //**************************************************************************
663635 /** Returns a list of tables and columns
664636 */
665- private ServiceResponse getTables (ServiceRequest request , Database database ) {
637+ public ServiceResponse getTables (ServiceRequest request , Database database ) {
666638 Connection conn = null ;
667639 try {
668640
669641 JSONArray arr = new JSONArray ();
670642 conn = database .getConnection ();
671643 for (Table table : Database .getTables (conn )){
672-
673- if (table .getName ().startsWith ("device_location_" )) continue ; //skip partition tables
674-
675644 JSONArray columns = new JSONArray ();
676645 for (Column column : table .getColumns ()){
646+
677647 JSONObject col = new JSONObject ();
678648 col .set ("name" , column .getName ());
679649 col .set ("type" , column .getType ());
@@ -685,6 +655,7 @@ private ServiceResponse getTables(ServiceRequest request, Database database) {
685655
686656 JSONObject json = new JSONObject ();
687657 json .set ("name" , table .getName ());
658+ json .set ("schema" , table .getSchema ());
688659 json .set ("columns" , columns );
689660 arr .add (json );
690661 }
0 commit comments