-
-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from rafal-kowalski/164-use-explicit-limit-in…
…-polling-query-for-postgresql Use explicit LIMIT in scheduler task polling query for PostgreSQL
- Loading branch information
Showing
7 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...uler/src/main/java/com/github/kagkarlsson/scheduler/jdbc/PostgreSqlJdbcCustomization.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (C) Gustav Karlsson | ||
* | ||
* Licensed 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 com.github.kagkarlsson.scheduler.jdbc; | ||
|
||
public class PostgreSqlJdbcCustomization extends DefaultJdbcCustomization { | ||
@Override | ||
public boolean supportsExplicitQueryLimitPart() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getQueryLimitPart(int limit) { | ||
return " LIMIT " + limit; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
.../src/test/java/com/github/kagkarlsson/scheduler/jdbc/PostgreSqlJdbcCustomizationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.kagkarlsson.scheduler.jdbc; | ||
|
||
import com.github.kagkarlsson.scheduler.EmbeddedPostgresqlExtension; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
class PostgreSqlJdbcCustomizationTest { | ||
@RegisterExtension | ||
public EmbeddedPostgresqlExtension postgres = new EmbeddedPostgresqlExtension(); | ||
|
||
AutodetectJdbcCustomization jdbcCustomization = new AutodetectJdbcCustomization(postgres.getDataSource()); | ||
|
||
@Test | ||
void test() { | ||
assertTrue(jdbcCustomization.supportsExplicitQueryLimitPart()); | ||
Arrays.asList(1, 5, 20, 100).forEach( | ||
it -> assertEquals(jdbcCustomization.getQueryLimitPart(it), " LIMIT " + it) | ||
); | ||
} | ||
} |