Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Move SqlBuilder method [DHIS2-16705] #19203

Merged
merged 70 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
b8a1966
fix: Update code
larshelge Nov 13, 2024
81e861b
fix: Update code
larshelge Nov 13, 2024
952657b
Merge branch 'master' into lars-dev
larshelge Nov 13, 2024
5eaeb3d
fix: Update code
larshelge Nov 13, 2024
2ac1d9d
fix: Update code
larshelge Nov 13, 2024
1a7ecbe
fix: Update code
larshelge Nov 13, 2024
3b1d516
fix: Update code
larshelge Nov 13, 2024
91e44ac
fix: Update code
larshelge Nov 13, 2024
1b46af6
fix: Update code
larshelge Nov 13, 2024
334379c
Merge branch 'master' into lars-dev
larshelge Nov 13, 2024
32de857
fix: Update code
larshelge Nov 13, 2024
23408ba
fix: Update code
larshelge Nov 13, 2024
10990c4
fix: Update code
larshelge Nov 13, 2024
99afbad
fix: Update code
larshelge Nov 13, 2024
f16ef96
fix: Update code
larshelge Nov 13, 2024
e292a23
fix: Update code
larshelge Nov 13, 2024
486776f
Merge branch 'master' into lars-dev
larshelge Nov 13, 2024
ca741d1
fix: Update code
larshelge Nov 14, 2024
8fdc695
fix: Update code
larshelge Nov 14, 2024
2c8abe8
fix: Update code
larshelge Nov 14, 2024
1da4c6a
fix: Update code
larshelge Nov 14, 2024
7dab403
fix: Update code
larshelge Nov 14, 2024
cf9e3b6
fix: Update code
larshelge Nov 14, 2024
a025ce6
fix: Update code
larshelge Nov 14, 2024
5a19093
Merge branch 'master' into lars-dev
larshelge Nov 14, 2024
b48fea5
fix: Update code
larshelge Nov 14, 2024
5910541
Merge branch 'master' into lars-dev
larshelge Nov 14, 2024
5c98cbe
Merge branch 'master' into lars-dev
larshelge Nov 15, 2024
9a8f4e4
fix: Update code
larshelge Nov 15, 2024
33dd76a
fix: Update code
larshelge Nov 15, 2024
f3847d1
fix: Update code
larshelge Nov 15, 2024
e3e2215
fix: Update code
larshelge Nov 15, 2024
4213d99
Merge branch 'master' into lars-dev
larshelge Nov 15, 2024
612c587
fix: Update code
larshelge Nov 15, 2024
c4ecc24
Merge branch 'master' into lars-dev
larshelge Nov 15, 2024
fd347f5
fix: Update code
larshelge Nov 15, 2024
3df3f70
fix: Update code
larshelge Nov 15, 2024
127f25a
fix: Update code
larshelge Nov 17, 2024
2af1fec
fix: Update code
larshelge Nov 17, 2024
7649246
Merge branch 'master' into lars-dev
larshelge Nov 17, 2024
221c724
Merge branch 'master' into lars-dev
larshelge Nov 17, 2024
06bffce
fix: Update code
larshelge Nov 17, 2024
655fee2
fix: Update code
larshelge Nov 18, 2024
8cbda99
fix: Update code
larshelge Nov 18, 2024
0eb8bcc
fix: Update code
larshelge Nov 18, 2024
d26bcb3
fix: Update code
larshelge Nov 18, 2024
c0722ec
Merge branch 'master' into lars-dev
larshelge Nov 18, 2024
e9423c3
fix: Update code
larshelge Nov 18, 2024
2c20571
fix: Update code
larshelge Nov 18, 2024
40d6c33
fix: Update code
larshelge Nov 18, 2024
6f5a1d6
Merge branch 'master' into lars-dev
larshelge Nov 18, 2024
f532475
fix: Update code
larshelge Nov 18, 2024
51e26bc
fix: Update code
larshelge Nov 18, 2024
6a2ace3
fix: Update code
larshelge Nov 18, 2024
3ceff8d
fix: Update code
larshelge Nov 18, 2024
fa4ffb9
Merge branch 'master' into lars-dev
larshelge Nov 18, 2024
13f8a01
fix: Update code
larshelge Nov 18, 2024
e27caad
fix: Update code
larshelge Nov 18, 2024
2ae8e58
Merge branch 'master' into lars-dev
larshelge Nov 18, 2024
5ed2410
fix: Update code
larshelge Nov 18, 2024
c828aa6
fix: Update code
larshelge Nov 18, 2024
8ce9a2d
fix: Update code
larshelge Nov 18, 2024
aaa7557
fix: Update code
larshelge Nov 18, 2024
b5a0cd2
Merge branch 'master' into lars-dev
larshelge Nov 18, 2024
fbcc596
fix: Update code
larshelge Nov 18, 2024
15dba5a
fix: Update code
larshelge Nov 18, 2024
b4ebd28
fix: Update code
larshelge Nov 18, 2024
e55866f
fix: Update code
larshelge Nov 18, 2024
001db10
Merge branch 'master' into lars-dev
larshelge Nov 18, 2024
387e0f6
fix: Update code
larshelge Nov 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ public String differenceInSeconds(String columnA, String columnB) {
return String.format("(unix_timestamp(%s) - unix_timestamp(%s))", columnA, columnB);
}

@Override
public String regexpMatch(String pattern) {
return String.format("regexp %s", pattern);
}

// Statements

@Override
Expand Down Expand Up @@ -353,9 +358,4 @@ public String createCatalog(String connectionUrl, String username, String passwo
public String dropCatalogIfExists() {
return String.format("drop catalog if exists %s;", quote(catalog));
}

@Override
public String regexpMatch(String pattern) {
return "REGEXP " + pattern;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ public String differenceInSeconds(String columnA, String columnB) {
return String.format("extract(epoch from (%s - %s))", columnA, columnB);
}

@Override
public String regexpMatch(String pattern) {
return String.format("~* %s", pattern);
}

// Statements

@Override
Expand Down Expand Up @@ -350,9 +355,4 @@ public String createCatalog(String connectionUrl, String username, String passwo
public String dropCatalogIfExists() {
return notSupported();
}

@Override
public String regexpMatch(String pattern) {
return "~* " + pattern;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ public interface SqlBuilder {
*/
String differenceInSeconds(String columnA, String columnB);

/**
* @param pattern the regular expression pattern to match against
* @return a regular expression matching clause.
*/
String regexpMatch(String pattern);

// Statements

/**
Expand Down Expand Up @@ -360,12 +366,4 @@ public interface SqlBuilder {
* @return a drop catalog if exists statement.
*/
String dropCatalogIfExists();

/**
* Returns the appropriate regexp matching syntax
*
* @param pattern The regexp pattern to match against
* @return The complete regexp matching clause for the current database
*/
String regexpMatch(String pattern);
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,14 @@ void testDifferenceInSeconds() {
sqlBuilder.quote("a", "startdate"), sqlBuilder.quote("b", "enddate")));
}

@Test
void testRegexpMatch() {
assertEquals("regexp test", sqlBuilder.regexpMatch("test"));
assertEquals("regexp \\d", sqlBuilder.regexpMatch("\\d"));
assertEquals("regexp ", sqlBuilder.regexpMatch(""));
assertEquals("regexp [a-z]\\w+\\d{3}", sqlBuilder.regexpMatch("[a-z]\\w+\\d{3}"));
}

// Statements

@Test
Expand Down Expand Up @@ -344,18 +352,4 @@ void testCountRows() {

assertEquals(expected, sqlBuilder.countRows(getTableA()));
}

@Test
void testRegexpMatch() {
assertEquals("REGEXP test", sqlBuilder.regexpMatch("test"));

// Test pattern with regex special characters
assertEquals("REGEXP \\d", sqlBuilder.regexpMatch("\\d"));

// Test empty string
assertEquals("REGEXP ", sqlBuilder.regexpMatch(""));

// Test complex regex pattern
assertEquals("REGEXP [a-z]\\w+\\d{3}", sqlBuilder.regexpMatch("[a-z]\\w+\\d{3}"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,15 @@ void testDifferenceInSeconds() {
sqlBuilder.quote("a", "startdate"), sqlBuilder.quote("b", "enddate")));
}

@Test
void testRegexpMatch() {
assertEquals("~* test", sqlBuilder.regexpMatch("test"));
assertEquals("~* ", sqlBuilder.regexpMatch(""));
assertEquals("~* null", sqlBuilder.regexpMatch(null));
assertEquals("~* .*[a-z]\\d+", sqlBuilder.regexpMatch(".*[a-z]\\d+"));
assertEquals("~* ", sqlBuilder.regexpMatch(" "));
}

// Statements

@Test
Expand Down Expand Up @@ -429,13 +438,4 @@ void testCreateIndexWithDescNullsLast() {
// then
assertEquals(expected, createIndexStmt);
}

@Test
void testRegexpMatch() {
assertEquals("~* test", sqlBuilder.regexpMatch("test"));
assertEquals("~* ", sqlBuilder.regexpMatch(""));
assertEquals("~* null", sqlBuilder.regexpMatch(null));
assertEquals("~* .*[a-z]\\d+", sqlBuilder.regexpMatch(".*[a-z]\\d+"));
assertEquals("~* ", sqlBuilder.regexpMatch(" "));
}
}
Loading