Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
usfalami committed Sep 11, 2024
1 parent 9a6159a commit 6c98584
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/usf/jquery/core/CombinedOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ default OperationColumn operation(JDBCType type, Object... args) {

@Override
default String id() {
return null;
return "CombinedOperator"; //do better
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/usf/jquery/core/DBColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ static NamedColumn allColumns(@NonNull DBView view) {
@Override
public String sql(QueryContext ctx) {
ctx.viewAlias(view);
return "*"; //lazy
return "*";
}

@Override
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/usf/jquery/core/Operator.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ static TypedOperator yearMonth() {//YYYY-MM
return new TypedOperator(VARCHAR, op, required(DATE, TIMESTAMP, TIMESTAMP_WITH_TIMEZONE));
}

static TypedOperator yearWeek() {//YYYY-'W'WW //!ISO
static TypedOperator yearWeek() {//YYYY-'W'WW
CombinedOperator op = args-> {
var col = requireNArgs(1, args, ()-> "yearWeek")[0];
return concat().operation(varchar().operation(year().operation(col)),
Expand All @@ -239,8 +239,9 @@ static TypedOperator monthDay() {//MM-DD
static TypedOperator hourMinute() {//HH:MM
CombinedOperator op = args-> {
var col = requireNArgs(1, args, ()-> "hourMinute")[0];
var time = JDBCType.typeOf(col).filter(t-> t == TIME).isPresent() ? col : time().operation(col);
return left().operation(varchar().operation(time), 5);
var tim = JDBCType.typeOf(col).filter(t-> t == TIME)
.map(t-> col).orElseGet(()-> time().operation(col));
return left().operation(varchar().operation(tim), 5);
};
return new TypedOperator(VARCHAR, op, required(TIME, TIMESTAMP, TIMESTAMP_WITH_TIMEZONE));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/usf/jquery/core/TypedOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public OperationColumn operation(Object... args) {
@Override // do not delegate this
public OperationColumn operation(JDBCType type, Object... args) {
return operator.is(CombinedOperator.class)
? operator.operation(type, args) //no sql
? operator.operation(type, parameterSet.assertArguments(args)) //no sql
: Operator.super.operation(type, args);
}

Expand Down

0 comments on commit 6c98584

Please sign in to comment.