[ 
https://issues.apache.org/jira/browse/STREAMPIPES-162?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17134148#comment-17134148
 ] 

Florian Micklich edited comment on STREAMPIPES-162 at 6/12/20, 11:43 AM:
-------------------------------------------------------------------------

Fixed  in JDBCClient

{code:java}
  protected int extendPreparedStatement(final Map<String, Object> event,
                                        StringBuilder s1, StringBuilder s2, int 
index, String preProperty, String pre)
      throws SpRuntimeException {
    checkConnected();
    for (Map.Entry<String, Object> pair : event.entrySet()) {
      if (pair.getValue() instanceof Map) {
        index = extendPreparedStatement((Map<String, Object>) pair.getValue(), 
s1, s2, index,
            pair.getKey() + "_", pre);
      } else {
        checkRegEx(pair.getKey(), "Columnname");
        parameters.put(pair.getKey(), new Parameterinfo(index, 
SqlAttribute.getFromObject(pair.getValue())));
        
s1.append(pre).append("\"").append(preProperty).append(pair.getKey().toLowerCase()).append("\"");
        s2.append(pre).append("?");
        index++;
      }
      pre = ", ";
    }
    return index;
  }
{code}

with adding

        
{code:java}
s1.append(pre).append("\"").append(preProperty).append(pair.getKey().toLowerCase()).append("\"");
 --> toLowerCase
{code}



This is tested with MySQL and IoTDB and Postgres





was (Author: micklich):
Fixed  in JDBCClient

{code:java}
  protected int extendPreparedStatement(final Map<String, Object> event,
                                        StringBuilder s1, StringBuilder s2, int 
index, String preProperty, String pre)
      throws SpRuntimeException {
    checkConnected();
    for (Map.Entry<String, Object> pair : event.entrySet()) {
      if (pair.getValue() instanceof Map) {
        index = extendPreparedStatement((Map<String, Object>) pair.getValue(), 
s1, s2, index,
            pair.getKey() + "_", pre);
      } else {
        checkRegEx(pair.getKey(), "Columnname");
        parameters.put(pair.getKey(), new Parameterinfo(index, 
SqlAttribute.getFromObject(pair.getValue())));
        
s1.append(pre).append("\"").append(preProperty).append(pair.getKey().toLowerCase()).append("\"");
        s2.append(pre).append("?");
        index++;
      }
      pre = ", ";
    }
    return index;
  }
{code}

with adding

        
s1.append(pre).append("\"").append(preProperty).append(pair.getKey().toLowerCase()).append("\"");
 --> toLowerCase


This is tested with MySQL and IoTDB and Postgres




> Postgres Column Names are case sentitiv and save leads to error
> ---------------------------------------------------------------
>
>                 Key: STREAMPIPES-162
>                 URL: https://issues.apache.org/jira/browse/STREAMPIPES-162
>             Project: StreamPipes
>          Issue Type: Bug
>            Reporter: Florian Micklich
>            Assignee: Florian Micklich
>            Priority: Major
>             Fix For: 0.67.0
>
>
> The database, schema and table is created as expected but during save in the 
> Postgres Sink
> but during save I get all the time:
>  Table 'testtable' was unexpectedly not found and gets recreated.
>  ERROR: column "randomText" of relation "testtable" does not exist
> So the first message is a little bit misleading, because the table
> exists but can't be found and will be recreated in an endless loop.
> The reason is because this statement during the
> generatePreparedStatement method:
>       INSERT INTO testschema.testtable ( "randomText", "randomNumber", 
> "count", "timestamp" ) VALUES ( 'c', 69, 83531, 1591611708415 );
> The problem here is that postgres uses lowercases for the column names.
> So instead of randomText then name has to be randomtext:
>       INSERT INTO testschema.testtable ( "randomtext", "randomnumber", 
> "count", "timestamp" ) VALUES ( 'c', 69, 83531, 1591611708415 )



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to