AMashenkov commented on code in PR #5218:
URL: https://github.com/apache/ignite-3/pull/5218#discussion_r1957976571


##########
modules/api/src/main/java/org/apache/ignite/lang/util/IgniteNameUtils.java:
##########
@@ -57,43 +52,78 @@ public static String parseSimpleName(String name) {
     }
 
     /**
-     * Creates a fully qualified name in canonical form, that is, enclosing 
each part of the identifier chain in double quotes.
+     * Parses fully qualified name.
      *
-     * @param schemaName Name of the schema.
-     * @param objectName Name of the object.
-     * @return Returns fully qualified name in canonical form.
+     * @param name Fully qualified name of the object in canonical form.
+     * @return List of identifiers, where each identifier within the full name 
chain will be either unquoted or converted to uppercase.
      */
-    // TODO https://issues.apache.org/jira/browse/IGNITE-24021: replace 
`quote` call with `quoteIfNeeded`
-    @Deprecated(forRemoval = true)
-    public static String canonicalName(String schemaName, String objectName) {
-        return quote(schemaName) + '.' + quote(objectName);
+    public static List<String> parseName(String name) {
+        ensureNotNullAndNotEmpty(name, "name");
+
+        List<String> identifiers = new ArrayList<>();
+        Tokenizer tokenizer = new Tokenizer(name);
+
+        do {
+            identifiers.add(tokenizer.nextToken());
+        } while (tokenizer.hasNext());
+
+        return identifiers;
     }
 
     /**
-     * Tests if given string is fully qualified name in canonical form or 
simple name.
+     * Creates a fully qualified name in canonical form, that is, enclosing 
each part of the identifier chain in double quotes.
      *
-     * @param s String to test.
-     * @return {@code True} if given string is fully qualified name in 
canonical form or simple name.
+     * @param schemaName Normalized name of the schema.
+     * @param objectName Normalized name of the object.
+     * @return Returns fully qualified name in canonical form.
      */
-    // TODO https://issues.apache.org/jira/browse/IGNITE-24021: drop this 
method.
-    @Deprecated(forRemoval = true)
-    public static boolean canonicalOrSimpleName(String s) {
-        return NAME_PATTER.matcher(s).matches();
+    public static String canonicalName(String schemaName, String objectName) {
+        return quoteIfNeeded(schemaName) + '.' + quoteIfNeeded(objectName);
     }
 
     /**
-     * Wraps the given name with double quotes, e.g. "myColumn" -&gt; 
"\"myColumn\""
+     * Wraps the given name with double quotes if it not uppercased non-quoted 
name, e.g. "myColumn" -&gt; "\"myColumn\"", "MYCOLUMN" -&gt;
+     * "MYCOLUMN"
      *
-     * @param name Object name.
+     * @param identifier Object identifier.
      * @return Quoted object name.
      */
-    // TODO https://issues.apache.org/jira/browse/IGNITE-24021 make it 
private, `quoteIfNeeded` should be used instead.
-    @Deprecated
-    public static String quote(String name) {
-        if (name == null || name.isEmpty()) {
-            return name;
+    public static String quoteIfNeeded(String identifier) {
+        ensureNotNullAndNotEmpty(identifier, "identifier");
+
+        if (!identifierStart(identifier.codePointAt(0)) && 
!Character.isUpperCase(identifier.codePointAt(0))) {
+            return quote(identifier);
         }
 
+        for (int pos = 0; pos < identifier.length(); pos++) {
+            int codePoint = identifier.codePointAt(pos);
+
+            if (!identifierExtend(codePoint) && 
!Character.isUpperCase(codePoint)) {

Review Comment:
   ```suggestion
               if (!(identifierStart || identifierExtend(codePoint)) || 
!Character.isUpperCase(codePoint)) {
   ```



-- 
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-unsubscr...@ignite.apache.org

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

Reply via email to