Skip to content

Commit 5cd6187

Browse files
author
synapticloop
committed
adding in all types for all databases
1 parent ad29942 commit 5cd6187

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2088
-60
lines changed

src/main/java/synapticloop/h2zero/H2ZeroParser.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import synapticloop.h2zero.validator.field.FieldPopulateForeignKeyValidator;
6666
import synapticloop.h2zero.validator.field.FieldPopulatePrimaryKeyValidator;
6767
import synapticloop.h2zero.validator.field.FieldPrimaryKeyTypeValidator;
68+
import synapticloop.h2zero.validator.field.FieldSerialNonPrimaryKeyValidator;
6869
import synapticloop.h2zero.validator.field.SQLite3FieldBlobValidator;
6970
import synapticloop.h2zero.validator.field.SQLite3FieldClobValidator;
7071
import synapticloop.h2zero.validator.field.SQLite3FieldPrimaryKeyValidator;
@@ -148,6 +149,7 @@ public class H2ZeroParser {
148149
validators.add(new FieldIgnoredKeysValidator());
149150
validators.add(new FieldNotNullLengthValidator());
150151
validators.add(new FieldPrimaryKeyTypeValidator());
152+
validators.add(new FieldSerialNonPrimaryKeyValidator());
151153

152154
validators.add(new SQLite3FieldBlobValidator());
153155
validators.add(new SQLite3FieldClobValidator());

src/main/java/synapticloop/h2zero/base/manager/BaseConnectionManager.java

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public static void setInt(PreparedStatement preparedStatement, int parameterInde
265265
}
266266

267267
/**
268-
* Set a SMALLINT datatype to a prepared statement with the value of the passed
268+
* Set a INTEGER datatype to a prepared statement with the value of the passed
269269
* in Integer, or the correct SQL null type if null
270270
*
271271
* @param preparedStatement The prepared statement
@@ -274,7 +274,21 @@ public static void setInt(PreparedStatement preparedStatement, int parameterInde
274274
*
275275
* @throws SQLException if something went horribly wrong
276276
*/
277-
public static void setSmallint(PreparedStatement preparedStatement, int parameterIndex, Integer value) throws SQLException {
277+
public static void setInteger(PreparedStatement preparedStatement, int parameterIndex, Integer value) throws SQLException {
278+
setInt(preparedStatement, parameterIndex, value);
279+
}
280+
281+
/**
282+
* Set a SMALLINT datatype to a prepared statement with the value of the passed
283+
* in Short, or the correct SQL null type if null
284+
*
285+
* @param preparedStatement The prepared statement
286+
* @param parameterIndex the index of the parameter
287+
* @param value the value to be set
288+
*
289+
* @throws SQLException if something went horribly wrong
290+
*/
291+
public static void setSmallint(PreparedStatement preparedStatement, int parameterIndex, Short value) throws SQLException {
278292
if(null == value) {
279293
preparedStatement.setNull(parameterIndex, Types.SMALLINT);
280294
} else {
@@ -292,7 +306,7 @@ public static void setSmallint(PreparedStatement preparedStatement, int paramete
292306
*
293307
* @throws SQLException if something went horribly wrong
294308
*/
295-
public static void setSmallserial(PreparedStatement preparedStatement, int parameterIndex, Integer value) throws SQLException {
309+
public static void setSmallserial(PreparedStatement preparedStatement, int parameterIndex, Short value) throws SQLException {
296310
setSmallint(preparedStatement, parameterIndex, value);
297311
}
298312

@@ -493,6 +507,42 @@ public static void setDouble(PreparedStatement preparedStatement, int parameterI
493507
}
494508
}
495509

510+
/**
511+
* Set a DECIMAL datatype to a prepared statement with the value of the passed
512+
* in double, or the correct SQL null type if null
513+
*
514+
* @param preparedStatement The prepared statement
515+
* @param parameterIndex the index of the parameter
516+
* @param value the value to be set
517+
*
518+
* @throws SQLException if something went horribly wrong
519+
*/
520+
public static void setDecimal(PreparedStatement preparedStatement, int parameterIndex, Double value) throws SQLException {
521+
if(null == value) {
522+
preparedStatement.setNull(parameterIndex, Types.DECIMAL);
523+
} else {
524+
preparedStatement.setDouble(parameterIndex, value);
525+
}
526+
}
527+
528+
/**
529+
* Set a REAL datatype to a prepared statement with the value of the passed
530+
* in double, or the correct SQL null type if null
531+
*
532+
* @param preparedStatement The prepared statement
533+
* @param parameterIndex the index of the parameter
534+
* @param value the value to be set
535+
*
536+
* @throws SQLException if something went horribly wrong
537+
*/
538+
public static void setReal(PreparedStatement preparedStatement, int parameterIndex, Double value) throws SQLException {
539+
if(null == value) {
540+
preparedStatement.setNull(parameterIndex, Types.REAL);
541+
} else {
542+
preparedStatement.setDouble(parameterIndex, value);
543+
}
544+
}
545+
496546
/**
497547
* Set a CLOB datatype to a prepared statement with the value of the passed
498548
* in clob, or the correct SQL null type if null
@@ -732,6 +782,15 @@ public static Float getNullableResultFloat(ResultSet resultSet, int index) throw
732782
return((Float)returnPossibleNullObject(resultSet, resultSet.getFloat(index)));
733783
}
734784

785+
public static Double getNullableResultDouble(ResultSet resultSet, int index) throws SQLException {
786+
return((Double)returnPossibleNullObject(resultSet, resultSet.getDouble(index)));
787+
}
788+
789+
public static Short getNullableResultShort(ResultSet resultSet, int index) throws SQLException {
790+
return((Short)returnPossibleNullObject(resultSet, resultSet.getShort(index)));
791+
}
792+
793+
735794
/**
736795
* Get the underlying combo pooled result set
737796
*
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package synapticloop.h2zero.base.validator;
2+
3+
import synapticloop.h2zero.base.validator.bean.ValidationBean;
4+
import synapticloop.h2zero.base.validator.bean.ValidationFieldBean;
5+
6+
/*
7+
* Copyright (c) 2013-2020 synapticloop.
8+
* All rights reserved.
9+
*
10+
* This source code and any derived binaries are covered by the terms and
11+
* conditions of the Licence agreement ("the Licence"). You may not use this
12+
* source code or any derived binaries except in compliance with the Licence.
13+
* A copy of the Licence is available in the file named LICENCE shipped with
14+
* this source code or binaries.
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the Licence is distributed on an "AS IS" BASIS, WITHOUT
18+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19+
* Licence for the specific language governing permissions and limitations
20+
* under the Licence.
21+
*/
22+
23+
24+
public class BigserialValidator extends ValidatorBase {
25+
26+
public BigserialValidator(String nmField, String value, int minLength, int maxLength, boolean allowNull) {
27+
super(nmField, value, minLength, maxLength, allowNull, false);
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package synapticloop.h2zero.base.validator;
2+
3+
import synapticloop.h2zero.base.validator.bean.ValidationBean;
4+
import synapticloop.h2zero.base.validator.bean.ValidationFieldBean;
5+
6+
/*
7+
* Copyright (c) 2013-2020 synapticloop.
8+
* All rights reserved.
9+
*
10+
* This source code and any derived binaries are covered by the terms and
11+
* conditions of the Licence agreement ("the Licence"). You may not use this
12+
* source code or any derived binaries except in compliance with the Licence.
13+
* A copy of the Licence is available in the file named LICENCE shipped with
14+
* this source code or binaries.
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the Licence is distributed on an "AS IS" BASIS, WITHOUT
18+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19+
* Licence for the specific language governing permissions and limitations
20+
* under the Licence.
21+
*/
22+
23+
24+
public class DoubleValidator extends ValidatorBase {
25+
26+
public DoubleValidator(String nmField, String value, int minLength, int maxLength, boolean allowNull) {
27+
super(nmField, value, minLength, maxLength, allowNull, false);
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package synapticloop.h2zero.base.validator;
2+
3+
import synapticloop.h2zero.base.validator.bean.ValidationBean;
4+
import synapticloop.h2zero.base.validator.bean.ValidationFieldBean;
5+
6+
/*
7+
* Copyright (c) 2013-2020 synapticloop.
8+
* All rights reserved.
9+
*
10+
* This source code and any derived binaries are covered by the terms and
11+
* conditions of the Licence agreement ("the Licence"). You may not use this
12+
* source code or any derived binaries except in compliance with the Licence.
13+
* A copy of the Licence is available in the file named LICENCE shipped with
14+
* this source code or binaries.
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the Licence is distributed on an "AS IS" BASIS, WITHOUT
18+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19+
* Licence for the specific language governing permissions and limitations
20+
* under the Licence.
21+
*/
22+
23+
24+
public class RealValidator extends ValidatorBase {
25+
26+
public RealValidator(String nmField, String value, int minLength, int maxLength, boolean allowNull) {
27+
super(nmField, value, minLength, maxLength, allowNull, false);
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package synapticloop.h2zero.base.validator;
2+
3+
import synapticloop.h2zero.base.validator.bean.ValidationBean;
4+
import synapticloop.h2zero.base.validator.bean.ValidationFieldBean;
5+
6+
/*
7+
* Copyright (c) 2013-2020 synapticloop.
8+
* All rights reserved.
9+
*
10+
* This source code and any derived binaries are covered by the terms and
11+
* conditions of the Licence agreement ("the Licence"). You may not use this
12+
* source code or any derived binaries except in compliance with the Licence.
13+
* A copy of the Licence is available in the file named LICENCE shipped with
14+
* this source code or binaries.
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the Licence is distributed on an "AS IS" BASIS, WITHOUT
18+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19+
* Licence for the specific language governing permissions and limitations
20+
* under the Licence.
21+
*/
22+
23+
24+
public class SerialValidator extends ValidatorBase {
25+
26+
public SerialValidator(String nmField, String value, int minLength, int maxLength, boolean allowNull) {
27+
super(nmField, value, minLength, maxLength, allowNull, false);
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package synapticloop.h2zero.base.validator;
2+
3+
import synapticloop.h2zero.base.validator.bean.ValidationBean;
4+
import synapticloop.h2zero.base.validator.bean.ValidationFieldBean;
5+
6+
/*
7+
* Copyright (c) 2013-2020 synapticloop.
8+
* All rights reserved.
9+
*
10+
* This source code and any derived binaries are covered by the terms and
11+
* conditions of the Licence agreement ("the Licence"). You may not use this
12+
* source code or any derived binaries except in compliance with the Licence.
13+
* A copy of the Licence is available in the file named LICENCE shipped with
14+
* this source code or binaries.
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the Licence is distributed on an "AS IS" BASIS, WITHOUT
18+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19+
* Licence for the specific language governing permissions and limitations
20+
* under the Licence.
21+
*/
22+
23+
24+
public class SmallintValidator extends ValidatorBase {
25+
26+
public SmallintValidator(String nmField, String value, int minLength, int maxLength, boolean allowNull) {
27+
super(nmField, value, minLength, maxLength, allowNull, false);
28+
}
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package synapticloop.h2zero.base.validator;
2+
3+
import synapticloop.h2zero.base.validator.bean.ValidationBean;
4+
import synapticloop.h2zero.base.validator.bean.ValidationFieldBean;
5+
6+
/*
7+
* Copyright (c) 2013-2020 synapticloop.
8+
* All rights reserved.
9+
*
10+
* This source code and any derived binaries are covered by the terms and
11+
* conditions of the Licence agreement ("the Licence"). You may not use this
12+
* source code or any derived binaries except in compliance with the Licence.
13+
* A copy of the Licence is available in the file named LICENCE shipped with
14+
* this source code or binaries.
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the Licence is distributed on an "AS IS" BASIS, WITHOUT
18+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19+
* Licence for the specific language governing permissions and limitations
20+
* under the Licence.
21+
*/
22+
23+
24+
public class SmallserialValidator extends ValidatorBase {
25+
26+
public SmallserialValidator(String nmField, String value, int minLength, int maxLength, boolean allowNull) {
27+
super(nmField, value, minLength, maxLength, allowNull, false);
28+
}
29+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package synapticloop.h2zero.model.field;
2+
3+
/*
4+
* Copyright (c) 2012-2020 synapticloop.
5+
*
6+
* All rights reserved.
7+
*
8+
* This source code and any derived binaries are covered by the terms and
9+
* conditions of the Licence agreement ("the Licence"). You may not use this
10+
* source code or any derived binaries except in compliance with the Licence.
11+
* A copy of the Licence is available in the file named LICENCE shipped with
12+
* this source code or binaries.
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the Licence is distributed on an "AS IS" BASIS, WITHOUT
16+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17+
* Licence for the specific language governing permissions and limitations
18+
* under the Licence.
19+
*/
20+
21+
import org.json.JSONObject;
22+
23+
import synapticloop.h2zero.exception.H2ZeroParseException;
24+
25+
public class BigserialField extends BaseField {
26+
27+
public BigserialField(JSONObject jsonObject) throws H2ZeroParseException {
28+
super(jsonObject);
29+
}
30+
31+
public BigserialField(JSONObject jsonObject, boolean isInField) throws H2ZeroParseException {
32+
super(jsonObject, isInField);
33+
}
34+
35+
@Override
36+
public String getJavaType() {
37+
return "Long";
38+
}
39+
40+
@Override
41+
public String getSqlJavaType() {
42+
return("Long");
43+
}
44+
45+
@Override
46+
public String getSqlNullType() {
47+
return("BIGINT");
48+
}
49+
50+
@Override
51+
public boolean getShouldEscape() {
52+
return false;
53+
}
54+
}

src/main/java/synapticloop/h2zero/model/field/DecimalField.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ public DecimalField(JSONObject jsonObject, boolean isInField) throws H2ZeroParse
3535

3636
@Override
3737
public String getJavaType() {
38-
return("Float");
38+
return("Double");
3939
}
4040

4141
@Override
4242
public String getSqlJavaType() {
43-
return("Float");
43+
return("Double");
4444
}
4545

4646
@Override

0 commit comments

Comments
 (0)