Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,11 @@ public float floatValue() {
public double doubleValue() {
return value;
}

@Override
public String toString() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, getName would be more correct here.
toString usually tells more about object.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jjtt would you please add getName method also?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem in the case mentioned in the PR description is that something ends up calling toString() to convert the Enum8/Enum16 in the db into a string returned by a query. So that something doesn't know that it should call getName().

I don't know which part decides that the column type is a String in Java. Maybe that should be changed to default to using an integer type for enums and then it wouldn't matter what the toString() of an EnumValue is?

In my use case I don't care about the integer value of the enum, but I'm sure I could change the query to explicitly return a string. This SELECT * is actually in integration test code that verifies the db content. IMO, production code shouldn't use SELECT * anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this also needs to be considered:

return (T) new EnumValue(name == null ? "<unknown>" : name, enum8Val);

so there are situations where the string value of the enum can be unknown to the driver?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases with Dynamic types it can be unknown. Theoretically.

As for the rest - It should be fixed may be in another place to make it aware about getName. We will look at it later.

return name;
}
}

/**
Expand Down