Uploaded image for project: 'Spring Data Commons'
  1. Spring Data Commons
  2. DATACMNS-363

Unicode characters not supported in property reference expressions

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.5.2, 1.6 RC1
    • Fix Version/s: 1.7 M1 (Codd)
    • Component/s: Core
    • Labels:
      None
    • Environment:
      All
    • Sprint:
      The Road To SpringOne, SpringOne Aftermath

      Description

      I have a class writing with Unicode.

      @Getter @Setter
      class TestEntity {
      Date 생일;
      String 이름;
      }

      I make repository method for this entity

      List<TestEntity> findBy생일And이름(Date d, String n);

      But this is failed.

      Caused by: org.springframework.data.mapping.PropertyReferenceException: No property 생일And이름 found for type TestEntity

      So I invest spring data source and found a Regex pattern is not valid in org.springframework.data.repository.query.parser.PartTree KEYWORD_TEMPLATE

      It is

      KEYWORD_TEMPLATE = "(%s)(?=
      p

      {Lu})";

      This is not for Unicode letter. Some language has no cases(no upper/lower).

      So I reference http://www.regular-expressions.info/unicode.html
      and Test with

      String KEYWORD_TEMPLATE = "(%s)(?=
      P{M}
      p{M}*+)";

      It works.


      Test code is below.


      @Test
      public void testFail_Not_Splited() {
      String KEYWORD_TEMPLATE = "(%s)(?=
      p{Lu}

      )";
      Pattern pattern = Pattern.compile(String.format(KEYWORD_TEMPLATE, "And"));
      String[] res = pattern.split("findBy생일And이름");
      assertEquals(1, res.length);
      assertEquals("findBy생일And이름", res[0]);
      }

      @Test
      public void testAlternative() {
      // Reference: http://www.regular-expressions.info/unicode.html
      String KEYWORD_TEMPLATE = "(%s)(?=
      P

      {M}
      p{M}

      *+)";
      Pattern pattern = Pattern.compile(String.format(KEYWORD_TEMPLATE, "And"));
      String[] res = pattern.split("findBy생일And이름");
      assertEquals(2, res.length);
      assertEquals("findBy생일", res[0]);
      assertEquals("이름", res[1]);
      }

        Attachments

          Activity

            People

            • Assignee:
              thomasd Thomas Darimont
              Reporter:
              narusas Jisung, Ahn
              Last updater:
              Trevor Marshall
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: