LeasyZhang opened a new issue #8946:
URL: https://github.com/apache/shardingsphere/issues/8946


   ## Bug Report
   
   **For English only**, other languages will not accept.
   
   Before report a bug, make sure you have:
   
   - Searched open and closed [GitHub 
issues](https://github.com/apache/shardingsphere/issues).
   - Read documentation: [ShardingSphere 
Doc](https://shardingsphere.apache.org/document/current/en/overview).
   
   Please pay attention on issues you submitted, because we maybe need more 
details. 
   If no response anymore and we cannot reproduce it on current information, we 
will **close it**.
   
   Please answer these questions before submitting your issue. Thanks!
   
   ### Which version of ShardingSphere did you use?
   4.1.1
   
   ### Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?
   ShardingSphere-JDBC
   
   ### Expected behavior
   Data should be inserted into table successfully.
   
   ### Actual behavior
   Insert failed and throw the following error message: 
   "column "content" is of type jsonb but expression is of type character 
varying"
   
   ### Reason analyze (If you can)
   ShardingSphere remove the jsonb function before it's processed by 
PgPreparedStatement. But it works on version 3.0.0.M1.
   
   ### Steps to reproduce the behavior, such as: SQL to execute, sharding rule 
configuration, when exception occur etc.
   
   - Prepare raw sql "insert into news(title, author, content) values (?, ?, 
?::jsonb)"
   - Do insert with PreparedStatement.executeUpdate method
   
   ### Example codes for reproduce this issue (such as a github link).
   `Session session = entityManager.unwrap(Session.class);
           return session.doReturningWork(connection -> {
               String sql = "insert into news(title, author, content) values 
(?, ?, ?::jsonb)";
               PreparedStatement ps = connection.prepareStatement(sql, 
Statement.RETURN_GENERATED_KEYS);
               int paramIndex = 1;
               ps.setString(paramIndex++, news.getTitle());
               ps.setString(paramIndex++, news.getAuthor());
               ps.setString(paramIndex, news.getContent());
               ps.executeUpdate();
               ResultSet result = ps.getGeneratedKeys();
               while (result.next()) {
                   news.setId(result.getLong(1));
               }
               ps.close();
               return news;
           });`
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to