Skip to content

Commit

Permalink
Dependencies are updated
Browse files Browse the repository at this point in the history
  • Loading branch information
solomax committed Aug 20, 2024
1 parent ae8c759 commit 3907d4e
Show file tree
Hide file tree
Showing 135 changed files with 19,398 additions and 19,387 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dependency-reduced-pom.xml
nb-configuration.xml
nbactions*.xml
.checkstyle
.vscode

7 changes: 7 additions & 0 deletions openjpa-features/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
/*
* 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
*
* http://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.openjpa.jdbc.kernel.exps;

/**
* OPENJPA-1794
* An aggregate unary operation that can indicate whether a null value from the data store
* should be returned as null.
*/
public abstract class NullableAggregateUnaryOp extends UnaryOp {
private static final long serialVersionUID = 1L;

public NullableAggregateUnaryOp(Val val) {
super(val);
}

public NullableAggregateUnaryOp(Val val, boolean noParen) {
super(val, noParen);
}

@Override
protected boolean nullableValue(ExpContext ctx, ExpState state) {
// If this is a simple operator (no joins involved), check compatibility to determine
// whether 'null' should be returned for the aggregate operation
if (ctx != null && ctx.store != null && (state.joins == null || state.joins.isEmpty())) {
return ctx.store.getConfiguration().getCompatibilityInstance().getReturnNullOnEmptyAggregateResult();
}
return false;
}
}
/*
* 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
*
* http://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.openjpa.jdbc.kernel.exps;

/**
* OPENJPA-1794
* An aggregate unary operation that can indicate whether a null value from the data store
* should be returned as null.
*/
public abstract class NullableAggregateUnaryOp extends UnaryOp {
private static final long serialVersionUID = 1L;

public NullableAggregateUnaryOp(Val val) {
super(val);
}

public NullableAggregateUnaryOp(Val val, boolean noParen) {
super(val, noParen);
}

@Override
protected boolean nullableValue(ExpContext ctx, ExpState state) {
// If this is a simple operator (no joins involved), check compatibility to determine
// whether 'null' should be returned for the aggregate operation
if (ctx != null && ctx.store != null && (state.joins == null || state.joins.isEmpty())) {
return ctx.store.getConfiguration().getCompatibilityInstance().getReturnNullOnEmptyAggregateResult();
}
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
/*
* 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
*
* http://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.openjpa.jdbc.kernel;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

/**
* <p>
* Tests SQLStoreQuery.substituteParams() behavior.
* </p>
*/

public class TestSQLStoreParamsSubstitution {

/**
* Tests parameter substitution algorithm to make sure the input sql is NOT transformed
* especially escape characters.
*/
@Test
public void testParamSubstitute() {

String sqlNrtns[][] = {
{
"like '5@%' escape '@'",
"[]"
},
// {
// "like '%#####_#%%' escape '#' WHERE ? = 'ab",
// "[1]"
// },
{
"SELECT 'TRUE' AS VAL FROM DUAL WHERE '\\' = ? AND 'Y' = 'Y'",
"[1]"
},
{
"like '*_n' escape '*' WHERE x = ? and y = ?",
"[1, 2]"
},
{
"like '%80@%%' escape '@' WHERE x = ? and y = ? or z=?" ,
"[1, 2, 3]"
},
{
"like '*_sql**%' escape '*" ,
"[]"
},
{ "SELECT 'TRUE' AS VAL FROM DUAL WHERE '\\' = ?",
"[1]",
},
{ "SELECT * FROM ("
+ "SELECT FOLDER_ID, SYS_CONNECT_BY_PATH(NAME,'\\') AS PATH FROM PROJECT_FOLDER "
+ "START WITH PARENT_ID IS NULL CONNECT BY PRIOR FOLDER_ID = PARENT_ID"
+ ") WHERE PATH LIKE ?",
"[1]"
}
};
try {
List<Integer> paramOrder = new ArrayList<>();

for (String sqlNrtn[] : sqlNrtns) {
paramOrder.clear();
String rtnSql = SQLStoreQuery.substituteParams(sqlNrtn[0], paramOrder);
assertEquals(sqlNrtn[0], rtnSql);
assertEquals(sqlNrtn[1], paramOrder.toString());
}
} catch (IOException e) {
fail("Unexpected Exception:" + e);
}
}
}
/*
* 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
*
* http://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.openjpa.jdbc.kernel;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;

/**
* <p>
* Tests SQLStoreQuery.substituteParams() behavior.
* </p>
*/

public class TestSQLStoreParamsSubstitution {

/**
* Tests parameter substitution algorithm to make sure the input sql is NOT transformed
* especially escape characters.
*/
@Test
public void testParamSubstitute() {

String sqlNrtns[][] = {
{
"like '5@%' escape '@'",
"[]"
},
// {
// "like '%#####_#%%' escape '#' WHERE ? = 'ab",
// "[1]"
// },
{
"SELECT 'TRUE' AS VAL FROM DUAL WHERE '\\' = ? AND 'Y' = 'Y'",
"[1]"
},
{
"like '*_n' escape '*' WHERE x = ? and y = ?",
"[1, 2]"
},
{
"like '%80@%%' escape '@' WHERE x = ? and y = ? or z=?" ,
"[1, 2, 3]"
},
{
"like '*_sql**%' escape '*" ,
"[]"
},
{ "SELECT 'TRUE' AS VAL FROM DUAL WHERE '\\' = ?",
"[1]",
},
{ "SELECT * FROM ("
+ "SELECT FOLDER_ID, SYS_CONNECT_BY_PATH(NAME,'\\') AS PATH FROM PROJECT_FOLDER "
+ "START WITH PARENT_ID IS NULL CONNECT BY PRIOR FOLDER_ID = PARENT_ID"
+ ") WHERE PATH LIKE ?",
"[1]"
}
};
try {
List<Integer> paramOrder = new ArrayList<>();

for (String sqlNrtn[] : sqlNrtns) {
paramOrder.clear();
String rtnSql = SQLStoreQuery.substituteParams(sqlNrtn[0], paramOrder);
assertEquals(sqlNrtn[0], rtnSql);
assertEquals(sqlNrtn[1], paramOrder.toString());
}
} catch (IOException e) {
fail("Unexpected Exception:" + e);
}
}
}
Loading

0 comments on commit 3907d4e

Please sign in to comment.