Menu

#618 sqlparam plugin asks for commented variables

None
closed-fixed
nobody
None
5
2018-12-22
2008-02-29
Anonymous
No

sqlParam plugin asks for variable values even when they are commented out (doesnt affect result).

Test machine:
- Windows XP
- Squirrel 2.6.4
- Oracle connection.

Example:

(works fine)
select 1 from dual
where 1 = 1

(works fine, asks for value)
select 1 from dual
where 1 = :my_param

(sql result is OK, but asks for value)
select 1 from dual
--where 1 = :my_param

(sql result is OK, but asks for value)
select 1 from dual
where 1 = 1 /* :my_param */

Discussion

  • Nobody/Anonymous

    Logged In: NO

    ask for param but its a casting (postgresql)
    Example:

    select my_int_field::varchar from table

    in postgres sql "::" stands for typecasting

     
  • mkls

    mkls - 2013-09-26

    fix for both problems (commented out params and "::"

    diff --git a/sql12/plugins/sqlparam/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlparam/SQLParamExecutionListener.java b/sql12/plugins/sqlparam/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlparam/SQLParamExecutionListener.j
    index 532329c..be31b73 100644
    --- a/sql12/plugins/sqlparam/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlparam/SQLParamExecutionListener.java
    +++ b/sql12/plugins/sqlparam/src/main/java/net/sourceforge/squirrel_sql/plugins/sqlparam/SQLParamExecutionListener.java
    @@ -79,10 +79,10 @@ public class SQLParamExecutionListener extends SQLExecutionAdapter
             */
            public String statementExecuting(String sql) {
                    // log.info("SQL starting to execute: " + sql);
    -               StringBuffer buffer = new StringBuffer(sql);
    +               StringBuffer buffer = new StringBuffer(sql.replaceAll("--.*", ""));
                    Map<String, String> cache = plugin.getCache();
                    Map<String, String> currentCache = new HashMap<String, String>();
    -               Pattern p = Pattern.compile(":[a-zA-Z]\\w+");
    +               Pattern p = Pattern.compile("[\\ \\(]:[a-zA-Z]\\w+");
    
                    Matcher m = p.matcher(buffer);
    
     

    Last edit: mkls 2013-09-27
  • Gerd Wagner

    Gerd Wagner - 2014-11-22
    • status: open --> closed-fixed
     
  • Gerd Wagner

    Gerd Wagner - 2014-11-22

    Is fixed in our Git repository and will be available in future snapshots and versions.

    Thanks to Michal Stekrt for the patch.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.