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

Develop #59

Merged
merged 310 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
310 commits
Select commit Hold shift + click to select a range
a3c61c0
edit
usfalami Jan 17, 2024
cd9c99a
edit
usfalami Jan 17, 2024
96fdef2
edit
usfalami Jan 18, 2024
5e6ba9f
edit
usfalami Jan 18, 2024
db574b8
edit
usfalami Jan 18, 2024
07ca3af
edit
usfalami Jan 19, 2024
23b24f7
edit
usfalami Jan 30, 2024
ffdf6c8
edit
usfalami Jan 31, 2024
9699cfd
edit
usfalami Jan 31, 2024
0e172f7
edit
usfalami Feb 4, 2024
ae525dc
edit
usfalami Feb 5, 2024
dc0499b
edit
usfalami Feb 5, 2024
06a3d91
edit
usfalami Feb 5, 2024
bafad37
edit
usfalami Feb 5, 2024
e10bc41
edit
usfalami Feb 6, 2024
7654a57
edit
usfalami Feb 6, 2024
0d4e976
edit
usfalami Feb 6, 2024
90cc164
edit
usfalami Feb 6, 2024
0e57e5f
edit
usfalami Feb 11, 2024
8154342
edit
usfalami Feb 11, 2024
de3ba9d
edit
usfalami Feb 11, 2024
1ee95cd
edit
usfalami Feb 13, 2024
7ab1577
edit
usfalami Feb 13, 2024
6eed070
edit
usfalami Feb 13, 2024
1388401
edit
usfalami Feb 13, 2024
7733044
edit
usfalami Feb 14, 2024
550ed42
edit
usfalami Feb 14, 2024
2228fed
edit
usfalami Feb 14, 2024
337d970
edit
usfalami Feb 14, 2024
4138071
eidt
usfalami Feb 18, 2024
8e20f0c
edit
usfalami Feb 20, 2024
dbce91f
edit
usfalami Feb 20, 2024
46efb81
edit
usfalami Feb 20, 2024
202fc4d
edit
usfalami Mar 6, 2024
ffa02fc
edit
usfalami Mar 6, 2024
67e05e4
edit
usfalami Mar 6, 2024
ec47fbf
edit
usfalami Jun 6, 2024
3c3ea01
edit
usfalami Jun 19, 2024
2dd1042
edit
usfalami Jul 2, 2024
c974ad3
edit
usfalami Jul 2, 2024
7fc642c
edit
usfalami Jul 2, 2024
7e908bd
edit
usfalami Jul 2, 2024
bdd137d
edit
usfalami Jul 3, 2024
bc332b4
edit
usfalami Jul 4, 2024
32446af
edit
usfalami Jul 24, 2024
e61f6d2
edit
usfalami Jul 25, 2024
caacd7a
edit
usfalami Jul 29, 2024
4de1272
edit
usfalami Jul 29, 2024
535e838
edit
usfalami Jul 31, 2024
d8aac23
edit
usfalami Jul 31, 2024
4a985dc
edit
usfalami Aug 1, 2024
39255b7
edit
usfalami Aug 2, 2024
0ce7611
edit
usfalami Aug 2, 2024
2643717
edit
usfalami Aug 2, 2024
8c5ff12
edit
usfalami Aug 3, 2024
1a1f8e4
edit
usfalami Aug 5, 2024
c743198
edit
usfalami Aug 5, 2024
8b5c5a7
edit
usfalami Aug 6, 2024
594bbf5
edit
usfalami Aug 6, 2024
84993f0
edit
usfalami Aug 7, 2024
6ad03b2
edit
usfalami Aug 7, 2024
9158f36
edit
usfalami Aug 7, 2024
d89723b
edit
usfalami Aug 7, 2024
c95525f
edit
usfalami Aug 9, 2024
ed74c85
edit
usfalami Aug 12, 2024
ecfd907
edit
usfalami Aug 12, 2024
c3710b3
edit
usfalami Aug 13, 2024
6093676
edit
usfalami Aug 13, 2024
7c8f298
edit
usfalami Aug 13, 2024
48b96ce
edit
usfalami Aug 13, 2024
6facbdc
edit
usfalami Aug 13, 2024
d8b2948
edit
usfalami Aug 13, 2024
bb8d4b6
edit
usfalami Aug 17, 2024
e10501e
edit
usfalami Aug 17, 2024
86617bc
edit
usfalami Aug 17, 2024
f8bb3cc
edit
usfalami Aug 17, 2024
b389ca6
edit
usfalami Aug 17, 2024
26c3df6
edit
usfalami Aug 17, 2024
af23bfc
edit
usfalami Aug 17, 2024
85d3203
edit
usfalami Aug 17, 2024
438ec75
edit
usfalami Aug 17, 2024
11bbd63
edit
usfalami Aug 17, 2024
a196ba2
edit
usfalami Aug 17, 2024
e39e10c
eidt
usfalami Aug 17, 2024
91670d3
edit
usfalami Aug 17, 2024
268d8a4
edit
usfalami Aug 18, 2024
443fb66
edit
usfalami Aug 18, 2024
7d6bc5a
edit
usfalami Aug 18, 2024
08e07d6
edit
usfalami Aug 18, 2024
315f324
edit
usfalami Aug 18, 2024
b171fda
edit
usfalami Aug 18, 2024
d8916d9
edit
usfalami Aug 19, 2024
343a55c
edit
usfalami Aug 19, 2024
d19d3c9
edit
usfalami Aug 19, 2024
9f39b55
edit
usfalami Aug 19, 2024
64ed42d
edit
usfalami Aug 19, 2024
26f9097
edit
usfalami Aug 20, 2024
f615b0a
edit
usfalami Aug 20, 2024
3efb3a6
edit
usfalami Aug 20, 2024
84fc7ed
edit
usfalami Aug 21, 2024
4d912ca
edit
usfalami Aug 21, 2024
d700e47
edit
usfalami Aug 21, 2024
c222fbb
edit
usfalami Aug 21, 2024
6de163d
edit
usfalami Aug 21, 2024
2ee56d1
edit
usfalami Aug 21, 2024
ab875f3
edit
usfalami Aug 21, 2024
83eb1fd
edit
usfalami Aug 21, 2024
baeb28f
edit
usfalami Aug 23, 2024
2baa8c9
edit
usfalami Aug 23, 2024
dfa8aaa
edit
usfalami Aug 23, 2024
b825c39
edit
usfalami Aug 23, 2024
0d6e0b3
Merge pull request #48 from oneteme/release-4.1.1
usfalami Aug 23, 2024
21d02b2
edit
usfalami Aug 23, 2024
6a9d65e
Merge pull request #49 from oneteme/release-4.1.1
usfalami Aug 23, 2024
8b92304
edit
usfalami Aug 23, 2024
33f16b2
edit
usfalami Aug 23, 2024
eacd8b1
edit
usfalami Aug 23, 2024
653bdff
edit
usfalami Aug 23, 2024
3977283
edit
usfalami Aug 24, 2024
eac4968
edit
usfalami Aug 24, 2024
a2dafd8
edit
usfalami Aug 24, 2024
1c1b186
edit
usfalami Aug 24, 2024
fa655db
edit
usfalami Aug 24, 2024
d55dd48
eidt
usfalami Aug 26, 2024
9aff924
edit
usfalami Aug 27, 2024
60c8499
edit
usfalami Aug 27, 2024
625a503
Merge branch 'release-4.1.1' into develop
usfalami Aug 27, 2024
0156a27
edit
usfalami Aug 27, 2024
8199e14
edit
usfalami Aug 27, 2024
b6fa61e
edit
usfalami Aug 27, 2024
8edf9fc
edit
usfalami Aug 27, 2024
c5521a9
edit
usfalami Aug 27, 2024
aa5b5ad
edit
usfalami Aug 27, 2024
396db5f
edit
usfalami Aug 27, 2024
9419996
eidt
usfalami Aug 27, 2024
91884fe
edit
usfalami Aug 28, 2024
6af7b27
edit
usfalami Aug 28, 2024
848f22b
edit
usfalami Aug 28, 2024
3187d36
edit
usfalami Aug 28, 2024
63748c6
edit
usfalami Aug 28, 2024
aa0e0fb
edit
usfalami Aug 28, 2024
971f506
edit
usfalami Aug 28, 2024
0ddb7b1
edit
usfalami Aug 28, 2024
25aecc1
edit
usfalami Aug 28, 2024
01b8b5d
edit
usfalami Aug 28, 2024
433f64d
edit
usfalami Aug 28, 2024
279a8f3
edit
usfalami Aug 28, 2024
4f4c7bb
edit
usfalami Aug 29, 2024
55df73a
edit
usfalami Aug 29, 2024
ef48ac5
edit
usfalami Aug 29, 2024
edc765f
edit
usfalami Aug 29, 2024
ce5f3d9
edit
usfalami Aug 29, 2024
92210be
edit
usfalami Aug 29, 2024
d377117
edit
usfalami Aug 29, 2024
4817878
edit
usfalami Aug 30, 2024
91039b0
edit
usfalami Aug 30, 2024
e4d2ea7
edit
usfalami Aug 30, 2024
621e1f2
edit
usfalami Aug 30, 2024
04ff171
edit
usfalami Aug 30, 2024
2fa90d6
edit
usfalami Sep 2, 2024
8f851b0
edit
usfalami Sep 2, 2024
920b2d5
editr
usfalami Sep 2, 2024
12bab79
edit
usfalami Sep 2, 2024
a98d058
edit
usfalami Sep 3, 2024
8e98a8b
edit
usfalami Sep 3, 2024
f31e811
edit
usfalami Sep 3, 2024
245f630
edit
usfalami Sep 4, 2024
9bf0638
edit
usfalami Sep 4, 2024
79524a2
edit
usfalami Sep 4, 2024
b9b528f
edit
usfalami Sep 4, 2024
9fd5498
edit
usfalami Sep 4, 2024
c91db64
edit
usfalami Sep 4, 2024
b1d6ccf
edit
usfalami Sep 4, 2024
b1db726
edit
usfalami Sep 4, 2024
196996a
edit
usfalami Sep 5, 2024
86244a3
edit
usfalami Sep 5, 2024
f13d069
edit
usfalami Sep 5, 2024
801cc02
edit
usfalami Sep 5, 2024
1539bf7
edit
usfalami Sep 6, 2024
105d749
edit
usfalami Sep 6, 2024
8dc8738
edit
usfalami Sep 6, 2024
d6e189e
edit
usfalami Sep 9, 2024
9c79b4c
edit
usfalami Sep 9, 2024
20b88be
edit
usfalami Sep 9, 2024
e0bfe55
edit
usfalami Sep 9, 2024
10928ef
edit
usfalami Sep 9, 2024
fca5874
edit
usfalami Sep 9, 2024
aa84fa4
edit
usfalami Sep 9, 2024
0b3c06f
edit
usfalami Sep 9, 2024
3b8f71a
edit
usfalami Sep 9, 2024
3da4433
edit
usfalami Sep 10, 2024
f3a7d29
edit
usfalami Sep 10, 2024
21b7332
edit
usfalami Sep 10, 2024
f389a3e
edit
usfalami Sep 10, 2024
4a36cde
edit
usfalami Sep 10, 2024
94310f0
edit
usfalami Sep 10, 2024
468310d
edit
usfalami Sep 10, 2024
092de88
edit
usfalami Sep 10, 2024
70636d5
edit
usfalami Sep 11, 2024
1c48648
edit
usfalami Sep 11, 2024
9a6159a
edit
usfalami Sep 11, 2024
6c98584
edit
usfalami Sep 11, 2024
0a2a70c
edit
usfalami Sep 11, 2024
a63ea67
edit
usfalami Sep 11, 2024
36fa42e
edit
usfalami Sep 11, 2024
b8788e8
edit
usfalami Sep 11, 2024
b9bc158
edit
usfalami Sep 11, 2024
972059c
edit
usfalami Sep 11, 2024
569000b
edit
usfalami Sep 11, 2024
eb2fe24
edit
usfalami Sep 11, 2024
936301d
edit
usfalami Sep 11, 2024
e758f81
edit
usfalami Sep 12, 2024
bb1cf1b
edit
usfalami Sep 12, 2024
3dc64c8
edit
usfalami Sep 12, 2024
94dfdc8
edit
usfalami Sep 12, 2024
e32c428
edit
usfalami Sep 12, 2024
d0e2266
edit
usfalami Sep 12, 2024
3bf21ce
edit
usfalami Sep 12, 2024
d547523
edit
usfalami Sep 12, 2024
7d1548e
edit
usfalami Sep 13, 2024
919fa53
edit
usfalami Sep 13, 2024
ec537fd
edit
usfalami Sep 16, 2024
abe048a
edit
usfalami Sep 16, 2024
f8bafeb
edit
usfalami Sep 16, 2024
3f2b7ef
edit
usfalami Sep 16, 2024
ccb7cc0
edit
usfalami Sep 16, 2024
4e25dd1
edit
usfalami Sep 16, 2024
038f0c7
edit
usfalami Sep 16, 2024
fb9bd84
edit
usfalami Sep 16, 2024
d36d450
eidt
usfalami Sep 17, 2024
cf1bca8
edit
usfalami Sep 17, 2024
2868e1d
edit
usfalami Sep 17, 2024
a93926e
edit
usfalami Sep 17, 2024
a51026c
eidt
usfalami Sep 17, 2024
452357d
edit
usfalami Sep 17, 2024
40970cc
edit
usfalami Sep 17, 2024
e27c68f
edit
usfalami Sep 17, 2024
2d3090f
edit
usfalami Sep 17, 2024
038f5ad
edit
usfalami Sep 17, 2024
a7bc8f4
edit
usfalami Sep 18, 2024
a09a3df
edit
usfalami Sep 18, 2024
7296bad
edit
usfalami Sep 18, 2024
2a3dccc
edit
usfalami Sep 18, 2024
97df2ec
edit
usfalami Sep 18, 2024
121f91e
edit
usfalami Sep 18, 2024
345141b
edit
usfalami Sep 18, 2024
8d3958e
edit
usfalami Sep 19, 2024
50b251d
edit
usfalami Sep 23, 2024
be19e6b
edit
usfalami Sep 25, 2024
0e30883
edit
usfalami Sep 25, 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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: Build & Scan Project
env:
Expand All @@ -44,7 +44,7 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.oneteme</groupId>
<artifactId>jquery</artifactId>
<version>3.0.0</version>
<version>4.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>java-query</name>
<description>java-query</description>
Expand All @@ -26,7 +26,7 @@
</license>
</licenses>
<properties>
<java.version>11</java.version>
<java.version>17</java.version>
<junit.version>5.8.1</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
Expand All @@ -39,13 +39,13 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<version>1.7.36</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
*
*/
@FunctionalInterface
public interface DBExpression extends DBObject {
public interface AggregateFunction extends FunctionOperator {

}
}
20 changes: 0 additions & 20 deletions src/main/java/org/usf/jquery/core/AggregationFunction.java

This file was deleted.

20 changes: 20 additions & 0 deletions src/main/java/org/usf/jquery/core/ArgTypeRef.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.usf.jquery.core;

import static org.usf.jquery.core.JDBCType.typeOf;
import static org.usf.jquery.core.Validation.requireAtLeastNArgs;

import java.util.function.Function;

/**
*
* @author u$f
*
*/
@FunctionalInterface
interface ArgTypeRef extends Function<Object[], JDBCType> {

static ArgTypeRef firstArgJdbcType() {
return arr-> typeOf(requireAtLeastNArgs(1, arr, ArgTypeRef.class::getSimpleName)[0])
.orElse(null);
}
}
22 changes: 22 additions & 0 deletions src/main/java/org/usf/jquery/core/ArithmeticOperator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.usf.jquery.core;

import static org.usf.jquery.core.Validation.requireNArgs;

/**
*
* @author u$f
*
*/
@FunctionalInterface
public interface ArithmeticOperator extends Operator {

@Override
default void sql(SqlStringBuilder sb, QueryContext ctx, Object[] args) {
requireNArgs(2, args, ArithmeticException.class::getSimpleName);
sb.parenthesis(()->{
ctx.appendLiteral(sb, args[0]);
sb.append(id());
ctx.appendLiteral(sb, args[1]);
});
}
}
22 changes: 6 additions & 16 deletions src/main/java/org/usf/jquery/core/AsciiResultMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
@Slf4j
@RequiredArgsConstructor
public final class AsciiResultMapper implements ResultMapper<Void> {
public final class AsciiResultMapper implements ResultSetMapper<Void> {

private static final int MAX_LENGTH = 50;

Expand Down Expand Up @@ -87,27 +87,17 @@ public Void map(ResultSet rs) throws SQLException {
}
writer.writeLine(div);
} catch (IOException e) {
throw new RuntimeException("error while mapping results", e);
throw new MappingException("error writing results", e);
}
log.info("{} rows mapped in {} ms", rw, currentTimeMillis() - bg);
return null;
}

private static boolean isNumer(int type) {
switch (type) {
case BOOLEAN:
case BIT:
case TINYINT:
case SMALLINT:
case INTEGER:
case BIGINT:
case REAL:
case FLOAT:
case DOUBLE:
case NUMERIC:
case DECIMAL: return true;
default: return false;
}
return switch (type) {
case BOOLEAN, BIT, TINYINT, SMALLINT, INTEGER, BIGINT, REAL, FLOAT, DOUBLE, NUMERIC, DECIMAL: yield true;
default: yield false;
};
}

private static Object[] array(int size, String v) {
Expand Down
42 changes: 42 additions & 0 deletions src/main/java/org/usf/jquery/core/BadArgumentException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.usf.jquery.core;

import static java.lang.String.format;
import static org.usf.jquery.core.SqlStringBuilder.SCOMA;
import static org.usf.jquery.core.Utils.joinAndDelemitArray;
import static org.usf.jquery.core.Utils.joinArray;

import org.usf.jquery.core.JavaType.Typed;

/**
*
* @author u$f
*
*/
@SuppressWarnings("serial")
public final class BadArgumentException extends JQueryException {

public BadArgumentException(String message) {
super(message);
}

public BadArgumentException(String message, Throwable cause) {
super(message, cause);
}

public static BadArgumentException badArgumentCountException(int count, int expect) {
return new BadArgumentException(format("bad argument count: [%d], expected: %d", count, expect));
}

public static BadArgumentException badArgumentTypeException(Object obj, JavaType[] types) {
var type = obj instanceof Typed t ? t.getType() : JDBCType.typeOf(obj);
return new BadArgumentException(format("bad argument type: %s[%s], expected: %s", obj, type, joinArray("|", types)));
}

public static BadArgumentException badArgumentsException(String type, String id, Object[] args, Exception e) {
return new BadArgumentException(format("bad %s arguments: ", type) + badArgumentsFormat(id, args), e);
}

public static String badArgumentsFormat(String id, Object... args) {
return id + joinAndDelemitArray(SCOMA, "([", "])", args);
}
}
14 changes: 5 additions & 9 deletions src/main/java/org/usf/jquery/core/BasicComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@
*
*/
@FunctionalInterface
public interface BasicComparator extends DBComparator {

String symbol();
public interface BasicComparator extends Comparator {

@Override
default String sql(QueryParameterBuilder builder, Object[] args) {
default void sql(SqlStringBuilder sb, QueryContext ctx, Object[] args) {
requireNArgs(2, args, BasicComparator.class::getSimpleName);
return builder.appendParameter(args[0]) + symbol() + builder.appendParameter(args[1]);
}

static BasicComparator basicComparator(final String name) {
return ()-> name;
ctx.appendParameter(sb, args[0]);
sb.append(id());
ctx.appendParameter(sb, args[1]);
}
}
59 changes: 30 additions & 29 deletions src/main/java/org/usf/jquery/core/CaseColumn.java
Original file line number Diff line number Diff line change
@@ -1,50 +1,51 @@
package org.usf.jquery.core;

import static java.util.stream.Collectors.joining;
import static org.usf.jquery.core.QueryParameterBuilder.addWithValue;
import static org.usf.jquery.core.SqlStringBuilder.SPACE;
import static org.usf.jquery.core.Validation.requireAtLeastNArgs;

import java.util.Collection;
import java.util.LinkedList;

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.stream.Stream;

/**
*
* @author u$f
*
*/
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public final class CaseColumn implements DBColumn {

private final Collection<WhenExpression> expressions = new LinkedList<>();
private final WhenCase[] whenCases;

CaseColumn(WhenCase[] whenCases) {
this.whenCases = requireAtLeastNArgs(1, whenCases, CaseColumn.class::getSimpleName);
}

@Override
public String sql(QueryParameterBuilder builder) {
builder.forceValue(true); //add filters as value
try {
return expressions.stream()
.map(o-> o.sql(builder))
.collect(joining(SPACE, "CASE ", " END"));
}
finally {
builder.forceValue(false);
}
public void sql(SqlStringBuilder sb, QueryContext ctx) {
var sub = ctx.withValue(); //force literal parameter
sb.runForeach(whenCases, SPACE, o-> o.sql(sb, sub), "CASE ", " END");
}

public CaseColumn append(WhenExpression we) {
expressions.add(we);
return this;

@Override
public JDBCType getType() {
return Stream.of(whenCases)
.map(WhenCase::getType)
.filter(Objects::nonNull) // should have same type
.findAny().orElse(null);
}

@Override
public String toString() {
return sql(addWithValue());
public int columns(QueryBuilder builder, Consumer<? super DBColumn> groupKeys) {
return Nested.resolveColumn(this, builder, groupKeys, whenCases);
}

public static CaseColumn caseWhen(DBFilter filter, Object value){
return new CaseColumn()
.append(new WhenExpression(filter, value));

@Override
public void views(Consumer<DBView> cons) {
Nested.resolveViews(cons, whenCases);
}

@Override
public String toString() {
return DBObject.toSQL(this);
}
}
Loading
Loading