Skip to content

Commit

Permalink
finished execute-api (#19)
Browse files Browse the repository at this point in the history
* finished execute-api

* added a missing test

* added another missing test-case
  • Loading branch information
Schubi1981 authored Jan 11, 2020
1 parent b6fe8e4 commit 21ea8b7
Show file tree
Hide file tree
Showing 45 changed files with 249 additions and 32 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A Java-Library to build SQL-Statements
<dependency>
<groupId>de.jaggl.sqlbuilder</groupId>
<artifactId>sqlbuilder-core</artifactId>
<version>2.5.2</version>
<version>2.6.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>de.jaggl.sqlbuilder</groupId>
<artifactId>sqlbuilder-core</artifactId>
<version>2.5.2</version>
<version>2.6.0</version>

<packaging>jar</packaging>

Expand Down
5 changes: 4 additions & 1 deletion src/main/java/de/jaggl/sqlbuilder/columns/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import de.jaggl.sqlbuilder.domain.Definable;
import de.jaggl.sqlbuilder.domain.Groupable;
import de.jaggl.sqlbuilder.domain.Selectable;
import de.jaggl.sqlbuilder.domain.SqlTypeSupplier;
import de.jaggl.sqlbuilder.schema.Table;
import de.jaggl.sqlbuilder.utils.BuilderUtils;
import de.jaggl.sqlbuilder.utils.Indentation;
Expand All @@ -21,7 +22,7 @@
@AllArgsConstructor
@Getter
@ToString
public abstract class Column implements Groupable, Selectable, Definable, NullableConditions, EqualityConditions
public abstract class Column implements Groupable, Selectable, Definable, NullableConditions, EqualityConditions, SqlTypeSupplier
{
@ToString.Exclude
protected Table table;
Expand All @@ -31,6 +32,8 @@ public abstract class Column implements Groupable, Selectable, Definable, Nullab

protected ColumnDefinition columnDefinition;

private int sqlType;

@Override
public String getValue(BuildingContext context, Indentation indentation)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.datetime;

import static java.sql.Types.DATE;

import java.time.ZonedDateTime;
import java.time.temporal.Temporal;
import java.util.function.Function;
Expand All @@ -26,7 +28,7 @@ public Function<ZonedDateTime, Temporal> getDateConversion()

public DateColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, DATE);
}

public DateColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.datetime;

import static java.sql.Types.TIMESTAMP;

import java.time.ZonedDateTime;
import java.time.temporal.Temporal;
import java.util.function.Function;
Expand All @@ -26,7 +28,7 @@ public Function<ZonedDateTime, Temporal> getDateConversion()

public DateTimeColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, TIMESTAMP);
}

public DateTimeColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
@ToString(callSuper = true)
public abstract class NumberColumn<T extends NumberColumn<T, N>, N extends Number> extends Column implements NumberConditions
{
public NumberColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
public NumberColumn(Table table, String name, String alias, ColumnDefinition columnDefinition, int sqlType)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, sqlType);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.number.doubletype;

import static java.sql.Types.DECIMAL;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class DecimalColumn extends DoubleTypeColumn<DecimalColumn>
{
public DecimalColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, DECIMAL);
}

public DecimalColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.number.doubletype;

import static java.sql.Types.DOUBLE;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class DoubleColumn extends DoubleTypeColumn<DoubleColumn>
{
public DoubleColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, DOUBLE);
}

public DoubleColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public abstract class DoubleTypeColumn<T extends DoubleTypeColumn<T>> extends Nu
FORMAT.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.GERMAN));
}

public DoubleTypeColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
public DoubleTypeColumn(Table table, String name, String alias, ColumnDefinition columnDefinition, int sqlType)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, sqlType);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.number.doubletype;

import static java.sql.Types.FLOAT;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class FloatColumn extends DoubleTypeColumn<FloatColumn>
{
public FloatColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, FLOAT);
}

public FloatColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.number.integer;

import static java.sql.Types.BIGINT;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class BigIntColumn extends IntegerColumn<BigIntColumn>
{
public BigIntColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, BIGINT);
}

public BigIntColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.number.integer;

import static java.sql.Types.INTEGER;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class IntColumn extends IntegerColumn<IntColumn>
{
public IntColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, INTEGER);
}

public IntColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
@ToString(callSuper = true)
public abstract class IntegerColumn<T extends IntegerColumn<T>> extends NumberColumn<T, Integer>
{
public IntegerColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
public IntegerColumn(Table table, String name, String alias, ColumnDefinition columnDefinition, int sqlType)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, sqlType);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.number.integer;

import static java.sql.Types.INTEGER;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class MediumIntColumn extends IntegerColumn<MediumIntColumn>
{
public MediumIntColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, INTEGER);
}

public MediumIntColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.number.integer;

import static java.sql.Types.SMALLINT;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class SmallIntColumn extends IntegerColumn<SmallIntColumn>
{
public SmallIntColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, SMALLINT);
}

public SmallIntColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.number.integer;

import static java.sql.Types.TINYINT;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class TinyIntColumn extends IntegerColumn<TinyIntColumn>
{
public TinyIntColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, TINYINT);
}

public TinyIntColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.string;

import static java.sql.Types.CHAR;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class CharColumn extends StringColumn<CharColumn>
{
CharColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, CHAR);
}

public CharColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
@ToString(callSuper = true)
public abstract class StringColumn<T extends StringColumn<T>> extends Column implements StringConditions
{
public StringColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
public StringColumn(Table table, String name, String alias, ColumnDefinition columnDefinition, int sqlType)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, sqlType);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.string;

import static java.sql.Types.VARCHAR;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class TextColumn extends StringColumn<TextColumn>
{
TextColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, VARCHAR);
}

public TextColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.jaggl.sqlbuilder.columns.string;

import static java.sql.Types.VARCHAR;

import de.jaggl.sqlbuilder.columns.ColumnDefinition;
import de.jaggl.sqlbuilder.schema.Table;
import lombok.ToString;
Expand All @@ -14,7 +16,7 @@ public class VarCharColumn extends StringColumn<VarCharColumn>
{
VarCharColumn(Table table, String name, String alias, ColumnDefinition columnDefinition)
{
super(table, name, alias, columnDefinition);
super(table, name, alias, columnDefinition, VARCHAR);
}

public VarCharColumn as(String alias)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ public class CombinedCondition extends Condition
public CombinedCondition(Condition condition)
{
this.conditions.add(condition);
addPlaceholderSqlTypes(condition.getPlaceholderSqlTypes());
}

public void append(Condition condition)
{
conditions.add(condition);
addPlaceholderSqlTypes(condition.getPlaceholderSqlTypes());
}

@Override
Expand Down Expand Up @@ -77,6 +79,7 @@ public static Condition getCopy(Condition condition)
copy.conditions = conditions;
copy.setType(condition.getType());
copy.setConcatenation(condition.getConcatenation());
copy.addPlaceholderSqlTypes(condition.getPlaceholderSqlTypes());
return copy;
}
return condition;
Expand Down
Loading

0 comments on commit 21ea8b7

Please sign in to comment.