Skip to content

Commit 6606e61

Browse files
Merge branch 'develop' into fb_pipelineJobDeserialization
2 parents 9120da8 + bd9551f commit 6606e61

20 files changed

Lines changed: 10770 additions & 28597 deletions

core/src/org/labkey/core/dialect/PostgreSqlNonConformingStringHandler.java renamed to api/src/org/labkey/api/data/dialect/BackslashEscapingStringHandler.java

Lines changed: 59 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,59 @@
1-
/*
2-
* Copyright (c) 2011-2026 LabKey Corporation
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
package org.labkey.core.dialect;
18-
19-
import org.apache.commons.lang3.StringUtils;
20-
import org.labkey.api.data.dialect.StandardDialectStringHandler;
21-
22-
/*
23-
* User: adam
24-
* Date: Aug 13, 2011
25-
* Time: 4:10:10 PM
26-
*/
27-
28-
// Adds support for backslash escaping in string literals
29-
public class PostgreSqlNonConformingStringHandler extends StandardDialectStringHandler
30-
{
31-
@Override
32-
public String quoteStringLiteral(String str)
33-
{
34-
return "'" + StringUtils.replace(StringUtils.replace(str, "\\", "\\\\"), "'", "''") + "'";
35-
}
36-
37-
38-
@Override
39-
protected int findEndOfStringLiteral(CharSequence sql, int current)
40-
{
41-
boolean skipNext = false;
42-
43-
while (current < sql.length())
44-
{
45-
char c = sql.charAt(current++);
46-
47-
if (skipNext)
48-
{
49-
skipNext = false;
50-
}
51-
else
52-
{
53-
if (c == '\\')
54-
{
55-
skipNext = true;
56-
continue;
57-
}
58-
else if (c == '\'')
59-
{
60-
break;
61-
}
62-
}
63-
}
64-
65-
return current;
66-
}
67-
}
1+
/*
2+
* Copyright (c) 2011-2026 LabKey Corporation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.labkey.api.data.dialect;
18+
19+
import org.apache.commons.lang3.Strings;
20+
21+
// Adds support for backslash escaping in string literals
22+
public class BackslashEscapingStringHandler extends StandardDialectStringHandler
23+
{
24+
@Override
25+
public String quoteStringLiteral(String str)
26+
{
27+
return "'" + Strings.CS.replace(Strings.CS.replace(str, "\\", "\\\\"), "'", "''") + "'";
28+
}
29+
30+
31+
@Override
32+
protected int findEndOfStringLiteral(CharSequence sql, int current)
33+
{
34+
boolean skipNext = false;
35+
36+
while (current < sql.length())
37+
{
38+
char c = sql.charAt(current++);
39+
40+
if (skipNext)
41+
{
42+
skipNext = false;
43+
}
44+
else
45+
{
46+
if (c == '\\')
47+
{
48+
skipNext = true;
49+
}
50+
else if (c == '\'')
51+
{
52+
break;
53+
}
54+
}
55+
}
56+
57+
return current;
58+
}
59+
}

api/src/org/labkey/api/data/dialect/SqlDialect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2415,7 +2415,7 @@ void testDialectStringHandler()
24152415
{
24162416
// quotes backslashes etc
24172417
for (String v : Arrays.asList("", "'", "\"", "\\", "''", "\\'", "\\\\'", "'''", "><&/%\\' \"1~\\!@$&'()\"_+{}-=[],.#\u2603\u00E4\u00F6\u00FC\u00C5"))
2418-
testEquals(v, new SQLFragment("SELECT ").appendStringLiteral(v,d));
2418+
testEquals(v, new SQLFragment("SELECT ").appendStringLiteral(v, d));
24192419

24202420
// test things that look like postgres escapes
24212421
// https://www.postgresql.org/docs/15/sql-syntax-lexical.html#SQL-SYNTAX-STRINGS-ESCAPE

api/src/org/labkey/api/data/dialect/StandardDialectStringHandler.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.labkey.api.data.dialect;
1818

1919
import org.apache.commons.lang3.StringUtils;
20+
import org.apache.commons.lang3.Strings;
2021
import org.junit.Assert;
2122
import org.junit.Test;
2223
import org.labkey.api.data.Parameter;
@@ -28,17 +29,12 @@
2829
import java.util.LinkedList;
2930
import java.util.List;
3031

31-
/*
32-
* User: adam
33-
* Date: Aug 13, 2011
34-
* Time: 3:55:55 PM
35-
*/
3632
public class StandardDialectStringHandler implements DialectStringHandler
3733
{
3834
@Override
3935
public String quoteStringLiteral(String str)
4036
{
41-
return "'" + StringUtils.replace(str, "'", "''") + "'";
37+
return "'" + Strings.CS.replace(str, "'", "''") + "'";
4238
}
4339

4440

assay/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = {
3636
'^.+\\.tsx?$': [
3737
'ts-jest',
3838
{
39-
tsconfig: 'node_modules/@labkey/build/webpack/tsconfig.test.json',
39+
tsconfig: 'node_modules/@labkey/build/configs/tsconfig.test.json',
4040
},
4141
],
4242
},

0 commit comments

Comments
 (0)