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

Add and fix tests. #38

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/at/avro/AvroField.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public AvroField(Column column, AvroConfig avroConfig) {
if (avroConfig.isAllFieldsDefaultNull()) {
defaultValue = null;
} else if (column.getDefaultValue() != null) {
defaultValue = column.getDefaultValue().contains("NULL") ? null : defaultValue;
defaultValue = column.getDefaultValue().contains("NULL") ? null : column.getDefaultValue();
}

if (avroConfig.isUseSqlCommentsAsDoc()) {
doc = column.getRemarks();
}
Expand All @@ -53,11 +53,11 @@ public Object getDefaultValue() {
public boolean isDefaultValueSet() {
return defaultValue != NOT_SET;
}

public String getDoc() {
return doc;
}

public boolean isDocSet() {
return StringUtils.isNotBlank(doc);
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/pgsql/avro/comment_table.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
{ "name": "created", "type": { "type": "long", "logicalType": "timestamp-millis", "java-class": "java.util.Date" } },
{ "name": "updated", "type": [ "null", { "type": "long", "logicalType": "timestamp-millis", "java-class": "java.util.Date" } ] },
{ "name": "decimal_field", "type": [ "null", { "type": "string", "java-class": "java.math.BigDecimal", "logicalType": "decimal", "precision": 20, "scale": 3 } ] },
{ "name": "other_decimal_field", "type": [ "null", { "type": "string", "java-class": "java.math.BigDecimal", "logicalType": "decimal", "precision": 131089, "scale": 0 } ] }
{ "name": "other_decimal_field", "type": [ "null", { "type": "string", "java-class": "java.math.BigDecimal", "logicalType": "decimal", "precision": 0, "scale": 0 } ] }
]
}
3 changes: 2 additions & 1 deletion src/test/resources/pgsql/avro/default_table.avsc
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
{ "name": "first_name", "type": "string" },
{ "name": "last_name", "type": [ "null", "string" ] },
{ "name": "address", "type": [ "null", "string" ], "default": null },
{ "name": "default_string", "type": [ "null", "string" ], "default": "'hello'::character varying" },
{ "name": "created", "type": { "type": "long", "logicalType": "timestamp-millis", "java-class": "java.util.Date" } },
{ "name": "updated", "type": [ "null", { "type": "long", "logicalType": "timestamp-millis", "java-class": "java.util.Date" } ] },
{ "name": "decimal_field", "type": [ "null", { "type": "string", "java-class": "java.math.BigDecimal", "logicalType": "decimal", "precision": 20, "scale": 3 } ] },
{ "name": "other_decimal_field", "type": [ "null", { "type": "string", "java-class": "java.math.BigDecimal", "logicalType": "decimal", "precision": 131089, "scale": 0 } ] },
{ "name": "other_decimal_field", "type": [ "null", { "type": "string", "java-class": "java.math.BigDecimal", "logicalType": "decimal", "precision": 0, "scale": 0 } ] },
{ "name": "cancelled", "type": [ "null", { "type": "long", "logicalType": "timestamp-millis", "java-class": "java.util.Date" } ] }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ create table default_table
"first_name" varchar(50) not null,
"last_name" varchar(50),
"address" varchar(50) default null,
"default_string" varchar(50) default 'hello',
"created" timestamp not null,
"updated" timestamp,
"decimal_field" decimal(20, 3),
Expand Down