Skip to content

Commit f31c6ed

Browse files
committed
fix tests
1 parent 3f82672 commit f31c6ed

File tree

50 files changed

+1138
-1314
lines changed

Some content is hidden

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

50 files changed

+1138
-1314
lines changed

fdb-relational-api/src/main/java/com/apple/foundationdb/relational/api/ArrayMetaData.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
package com.apple.foundationdb.relational.api;
2222

2323
import com.apple.foundationdb.relational.api.exceptions.ErrorCode;
24+
import com.apple.foundationdb.relational.api.metadata.DataType;
2425

26+
import javax.annotation.Nonnull;
2527
import java.sql.SQLException;
2628
import java.sql.Wrapper;
2729

@@ -59,4 +61,7 @@ default StructMetaData getElementStructMetaData() throws SQLException {
5961
* @throws SQLException if the type of the column is not an array, or if something else goes wrong.
6062
*/
6163
ArrayMetaData getElementArrayMetaData() throws SQLException;
64+
65+
@Nonnull
66+
DataType.ArrayType getRelationalDataType() throws SQLException;
6267
}

fdb-relational-api/src/main/java/com/apple/foundationdb/relational/api/FieldDescription.java

Lines changed: 0 additions & 205 deletions
This file was deleted.

fdb-relational-api/src/main/java/com/apple/foundationdb/relational/api/RelationalArrayBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import javax.annotation.Nonnull;
2424
import java.sql.SQLException;
25+
import java.util.UUID;
2526

2627
/**
2728
* Builder for {@link RelationalArray}.
@@ -44,5 +45,7 @@ public interface RelationalArrayBuilder {
4445

4546
RelationalArrayBuilder addLong(@Nonnull long value) throws SQLException;
4647

48+
RelationalArrayBuilder addUuid(@Nonnull UUID value) throws SQLException;
49+
4750
RelationalArrayBuilder addStruct(RelationalStruct struct) throws SQLException;
4851
}

fdb-relational-api/src/main/java/com/apple/foundationdb/relational/api/RelationalArrayMetaData.java

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
package com.apple.foundationdb.relational.api;
2222

2323
import com.apple.foundationdb.annotation.API;
24-
2524
import com.apple.foundationdb.relational.api.exceptions.ErrorCode;
2625
import com.apple.foundationdb.relational.api.exceptions.RelationalException;
27-
26+
import com.apple.foundationdb.relational.api.metadata.DataType;
2827
import com.google.common.base.Suppliers;
2928

3029
import javax.annotation.Nonnull;
30+
import java.sql.DatabaseMetaData;
3131
import java.sql.SQLException;
32-
import java.sql.Types;
3332
import java.util.Objects;
3433
import java.util.function.Supplier;
3534

@@ -39,41 +38,37 @@
3938
@API(API.Status.EXPERIMENTAL)
4039
public final class RelationalArrayMetaData implements ArrayMetaData {
4140

42-
private final FieldDescription element;
41+
private final DataType.ArrayType type;
4342

4443
private final Supplier<Integer> hashCodeSupplier;
4544

46-
private RelationalArrayMetaData(@Nonnull FieldDescription element) {
47-
this.element = element;
45+
public RelationalArrayMetaData(@Nonnull DataType.ArrayType type) {
46+
this.type = type;
4847
this.hashCodeSupplier = Suppliers.memoize(this::calculateHashCode);
4948
}
5049

51-
public static RelationalArrayMetaData ofPrimitive(int sqlType, int nullable) {
52-
return new RelationalArrayMetaData(FieldDescription.primitive("VALUE", sqlType, nullable));
53-
}
54-
55-
public static RelationalArrayMetaData ofStruct(@Nonnull StructMetaData metaData, int nullable) {
56-
return new RelationalArrayMetaData(FieldDescription.struct("VALUE", nullable, metaData));
57-
}
58-
5950
@Override
60-
public int isElementNullable() throws SQLException {
61-
return element.isNullable();
51+
public int isElementNullable() {
52+
if (type.getElementType().isNullable()) {
53+
return DatabaseMetaData.columnNullable;
54+
} else {
55+
return DatabaseMetaData.columnNoNulls;
56+
}
6257
}
6358

6459
@Override
6560
public String getElementName() throws SQLException {
66-
return element.getName();
61+
return "VALUE";
6762
}
6863

6964
@Override
7065
public int getElementType() throws SQLException {
71-
return element.getSqlTypeCode();
66+
return type.getElementType().getJdbcSqlCode();
7267
}
7368

7469
@Override
75-
public String getElementTypeName() throws SQLException {
76-
return SqlTypeNamesSupport.getSqlTypeName(element.getSqlTypeCode());
70+
public String getElementTypeName() {
71+
return SqlTypeNamesSupport.getSqlTypeName(type.getElementType().getJdbcSqlCode());
7772
}
7873

7974
/**
@@ -85,11 +80,11 @@ public String getElementTypeName() throws SQLException {
8580
* @throws SQLException if the type of the column is not a struct, or if something else goes wrong.
8681
*/
8782
@Override
88-
public StructMetaData getElementStructMetaData() throws SQLException {
89-
if (element.getSqlTypeCode() != Types.STRUCT) {
83+
public RelationalStructMetaData getElementStructMetaData() throws SQLException {
84+
if (type.getElementType().getCode() != DataType.Code.STRUCT) {
9085
throw new RelationalException("Element is not of STRUCT type", ErrorCode.CANNOT_CONVERT_TYPE).toSqlException();
9186
}
92-
return element.getFieldMetaData();
87+
return new RelationalStructMetaData((DataType.StructType) type.getElementType());
9388
}
9489

9590
/**
@@ -102,15 +97,21 @@ public StructMetaData getElementStructMetaData() throws SQLException {
10297
*/
10398
@Override
10499
public ArrayMetaData getElementArrayMetaData() throws SQLException {
105-
if (element.getSqlTypeCode() != Types.ARRAY) {
100+
if (type.getElementType().getCode() != DataType.Code.ARRAY) {
106101
throw new RelationalException("Element is not of ARRAY type", ErrorCode.CANNOT_CONVERT_TYPE).toSqlException();
107102
}
108-
return element.getArrayMetaData();
103+
return new RelationalArrayMetaData((DataType.ArrayType) type.getElementType());
104+
}
105+
106+
@Nonnull
107+
@Override
108+
public DataType.ArrayType getRelationalDataType() throws SQLException {
109+
return type;
109110
}
110111

111112
@Nonnull
112-
public FieldDescription getElementField() {
113-
return element;
113+
public DataType getElementDataType() {
114+
return type.getElementType();
114115
}
115116

116117
@Override
@@ -132,7 +133,7 @@ public boolean equals(Object other) {
132133
if (otherMetadata == this) {
133134
return true;
134135
}
135-
return element.equals(otherMetadata.element);
136+
return type.equals(otherMetadata.type);
136137
}
137138

138139
@Override
@@ -141,7 +142,7 @@ public int hashCode() {
141142
}
142143

143144
private int calculateHashCode() {
144-
return Objects.hash(element);
145+
return Objects.hash(type);
145146
}
146147

147148
}

fdb-relational-api/src/main/java/com/apple/foundationdb/relational/api/RelationalStructBuilder.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javax.annotation.Nonnull;
2424
import javax.annotation.Nullable;
2525
import java.sql.SQLException;
26+
import java.util.UUID;
2627

2728
/**
2829
* For implementation by {@link RelationalStruct} <a href="https://refactoring.guru/design-patterns/builder">Builder</a>.
@@ -40,8 +41,6 @@ public interface RelationalStructBuilder {
4041

4142
RelationalStructBuilder addBoolean(String fieldName, boolean b) throws SQLException;
4243

43-
RelationalStructBuilder addShort(String fieldName, short b) throws SQLException;
44-
4544
RelationalStructBuilder addLong(String fieldName, long l) throws SQLException;
4645

4746
RelationalStructBuilder addFloat(String fieldName, float f) throws SQLException;
@@ -52,7 +51,9 @@ public interface RelationalStructBuilder {
5251

5352
RelationalStructBuilder addString(String fieldName, @Nullable String s) throws SQLException;
5453

55-
RelationalStructBuilder addObject(String fieldName, @Nullable Object obj, int targetSqlType) throws SQLException;
54+
RelationalStructBuilder addUuid(String fieldName, @Nullable UUID uuid) throws SQLException;
55+
56+
RelationalStructBuilder addObject(String fieldName, @Nullable Object obj) throws SQLException;
5657

5758
RelationalStructBuilder addStruct(String fieldName, @Nonnull RelationalStruct struct) throws SQLException;
5859

0 commit comments

Comments
 (0)