You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "zihaoAK47 (via GitHub)" <gi...@apache.org> on 2023/06/06 11:05:45 UTC

[GitHub] [shardingsphere] zihaoAK47 opened a new pull request, #26079: Support table name backquote parse

zihaoAK47 opened a new pull request, #26079:
URL: https://github.com/apache/shardingsphere/pull/26079

   Fixes #26035.
   
   Changes proposed in this pull request:
     - Support table name backquote parse
     - Add test sql
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [ ✓] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [ ✓] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [ ✓] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ✓] I have added corresponding unit tests for my changes.
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] RaigorJiang commented on a diff in pull request #26079: Support table name backquote parse

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on code in PR #26079:
URL: https://github.com/apache/shardingsphere/pull/26079#discussion_r1220684801


##########
test/it/parser/src/main/resources/case/ddl/create-table.xml:
##########
@@ -17,6 +17,12 @@
   -->
 
 <sql-parser-test-cases>
+    <create-table sql-case-id="create_table_with_backtick">
+        <table name="t_order" start-delimiter="`" end-delimiter="`" start-index="13" stop-index="23" />

Review Comment:
   Hi @zihaoAK47 
   In #26035, We know that the expected table name should be `t_order, but now the result of the test is t_order, is this not as expected?
   
   
   The following is my test in native mysql:
   <img width="561" alt="image" src="https://github.com/apache/shardingsphere/assets/5668787/b08a3ff6-30a4-4790-b96c-554db62b221c">
   



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] RaigorJiang commented on a diff in pull request #26079: Support table name backquote parse

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on code in PR #26079:
URL: https://github.com/apache/shardingsphere/pull/26079#discussion_r1221939660


##########
test/it/parser/src/main/resources/case/ddl/create-table.xml:
##########
@@ -17,6 +17,12 @@
   -->
 
 <sql-parser-test-cases>
+    <create-table sql-case-id="create_table_with_backtick">
+        <table name="t_order" start-delimiter="`" end-delimiter="`" start-index="13" stop-index="23" />

Review Comment:
   Hi @zihaoAK47 
   There is a method `getQuotedContent` in `IdentifierValue`, which is used to obtain the complete content in the quotation marks. Do you think this method can meet the requirements?
   
   ```java
   public static String getQuotedContent(final String text) {
           if (Strings.isNullOrEmpty(text)) {
               return text;
           }
           QuoteCharacter quoteCharacter = QuoteCharacter.getQuoteCharacter(text);
           if (QuoteCharacter.NONE == quoteCharacter) {
               return text.trim();
           }
           return text.substring(1, text.length() - 1);
       }
   ```



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zihaoAK47 commented on pull request #26079: Support table name backquote parse

Posted by "zihaoAK47 (via GitHub)" <gi...@apache.org>.
zihaoAK47 commented on PR #26079:
URL: https://github.com/apache/shardingsphere/pull/26079#issuecomment-1578529759

   @RaigorJiang Hi mentor, although the backticks have been removed from IdentifierValue, it can still correctly create tables. I tested it using shardingsphere-proxy on my local machine and the table names were correct. The test statements have been modified and the code has passed the tests.
   
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] RaigorJiang merged pull request #26079: Support table name backquote parse

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang merged PR #26079:
URL: https://github.com/apache/shardingsphere/pull/26079


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zihaoAK47 commented on a diff in pull request #26079: Support table name backquote parse

Posted by "zihaoAK47 (via GitHub)" <gi...@apache.org>.
zihaoAK47 commented on code in PR #26079:
URL: https://github.com/apache/shardingsphere/pull/26079#discussion_r1221379265


##########
test/it/parser/src/main/resources/case/ddl/create-table.xml:
##########
@@ -17,6 +17,12 @@
   -->
 
 <sql-parser-test-cases>
+    <create-table sql-case-id="create_table_with_backtick">
+        <table name="t_order" start-delimiter="`" end-delimiter="`" start-index="13" stop-index="23" />

Review Comment:
   @RaigorJiang Sorry, I misunderstood the purpose of the start-delimiter and end-delimiter attributes for processing backticks. I have now created a new method to retrieve the correct table name enclosed with backticks. Please check it, mentor.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zihaoAK47 commented on a diff in pull request #26079: Support table name backquote parse

Posted by "zihaoAK47 (via GitHub)" <gi...@apache.org>.
zihaoAK47 commented on code in PR #26079:
URL: https://github.com/apache/shardingsphere/pull/26079#discussion_r1222404686


##########
test/it/parser/src/main/resources/case/ddl/create-table.xml:
##########
@@ -17,6 +17,12 @@
   -->
 
 <sql-parser-test-cases>
+    <create-table sql-case-id="create_table_with_backtick">
+        <table name="t_order" start-delimiter="`" end-delimiter="`" start-index="13" stop-index="23" />

Review Comment:
   @RaigorJiang Tutor, I think the IdentifierValue.getQuotedContent(final String text) method is sufficient if we only need to retrieve the content that is enclosed by special characters, but this method cannot obtain the actual content, such as the real table name of \`t_order\` , which is t_order.
   \`\`\`t_order\`  real table name is  \`t_order
   
   I am confused about whether the IdentifierValue property in the TableNameSegment class should represent the real table name. After processing with IdentifierValue.getQuotedContent, \`\`\`t_orde\` is transformed into \`\`t_order. However, I believe that the IdentifierValue property should represent the real table name, which should be \`t_order instead of \`\`t_order.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] RaigorJiang commented on pull request #26079: Support table name backquote parse

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on PR #26079:
URL: https://github.com/apache/shardingsphere/pull/26079#issuecomment-1583916384

   Thank you guys!


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org