jamesfredley commented on code in PR #16631:
URL: https://github.com/apache/grails-core/pull/16631#discussion_r4365443650


##########
grails-datamapping-core/src/main/groovy/org/apache/grails/data/core/querytail/H2SqlSyntax.groovy:
##########
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.grails.data.core.querytail
+
+import groovy.transform.CompileStatic
+import groovy.transform.PackageScope
+
+/**
+ * H2: block comments nest, {@code //} starts a line comment, {@code $$} 
quotes a string without a
+ * tag, backticks delimit a name in every compatibility mode, and square 
brackets delimit a name in
+ * the SQL Server mode, where they are never a subscript, which is what a 
bracket after a name, a
+ * closing parenthesis or a closing bracket is in the other modes.
+ */
+@CompileStatic
+@PackageScope
+final class H2SqlSyntax extends StandardSqlSyntax {
+
+    H2SqlSyntax() {
+        super('H2')
+    }
+
+    @Override
+    int endOfComment(String sql, int index) {
+        sql.startsWith('//', index) ? endOfLine(sql, index) : 
super.endOfComment(sql, index)
+    }
+
+    @Override
+    int endOfValue(String sql, int index) {
+        int end = endOfDollarQuoted(sql, index, false)
+        end != NONE ? end : super.endOfValue(sql, index)
+    }
+
+    @Override
+    int endOfQuotedName(String sql, int index) {
+        char c = sql.charAt(index)
+        if (c == '`') {
+            return endOfQuoted(sql, index, '`' as char, false, true)
+        }
+        if (c == '[' && !subscript(sql, index)) {

Review Comment:
   A space before `[` is still treated as a quoted identifier. `select ARRAY 
['example-secret']` is valid H2, and the redactor copies that span unchanged. A 
comment between `ARRAY` and `[` does the same.
   
   Do not treat brackets after whitespace as an identifier when they open an 
array, or withhold the statement. The existing array regression covers 
`array[7,8]` only, with no space. Please assert this literal does not reach the 
file.



-- 
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: [email protected]

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

Reply via email to