-
Notifications
You must be signed in to change notification settings - Fork 566
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
Table field naming convention issues #1474
Comments
This can be affected by too many things, not just Helidon. I don't have access to your DB so please verify few things first.
If metaData.getColumnLabel(i) returns case-sensitive names and Helidon does not, it's bug in Helidon. |
This problem should be caused by PostgreSQL itself. I know camel-case naming maybe not a good option for RDBMS. |
@hantsy It's worth investigating it. @Tomas-Kraus can you simulate it based on the sample code here https://blog.xojo.com/2016/09/28/about-postgresql-case-sensitivity/ and make sure that DB Client doesn't have problems with case sensitivity. |
I confirmed this is a PostgreSQL issue(maybe convention in PostgreSQL). I defined a table like this. CREATE TABLE IF NOT EXISTS Person(
ID UUID DEFAULT uuid_generate_v4() ,
FullName VARCHAR(255) NOT NULL,
Email VARCHAR(255) NOT NULL,
createdAt TIMESTAMP NOT NULL DEFAULT LOCALTIMESTAMP ,
PRIMARY KEY (ID)
); And create a jdbc sample to connect the database and println the metadata of table Persone. public class JdbcMetadataSample {
private final String url = "jdbc:postgresql://localhost/test";
private final String user = "user";
private final String password = "password";
public void printPersonTableMetadata() {
Connection conn = null;
try {
conn = DriverManager.getConnection(url, user, password);
System.out.println("Connected to the PostgreSQL server successfully.");
var statement = conn.prepareStatement("select FullName, EMAIL, createdAt from PERSON");
ResultSet rs = statement.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String label = metaData.getColumnLabel(i);
String name = metaData.getColumnName(i);
System.out.println("label:" + label);
System.out.println("name:" + name);
}
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
public static void main(String[] args) {
JdbcMetadataSample app = new JdbcMetadataSample();
app.printPersonTableMetadata();
}
} It prints the following results. Connected to the PostgreSQL server successfully.
label:fullname
name:fullname
label:email
name:email
label:createdat
name:createdat The column name and table name in the SQL are case-insensitive, and in the JDBC metadata, all become lowercase. |
That's right; |
Integration tests are running with MySQL. But maybe it's time to add few more databases. |
Closing this. Created #1518 to setup PgSQL integration tests. |
I used PostgreSQL in Docker for tests.
When I defined the createdAt as TIMESTAMP like this.
Then I tried to fetch this field via
DbRow
, I found the field name is createdat, not createdAt. I am not sure this is the design purpose or an issue.(I have changed my codes to use
created_at
as the field name finally to avoid this issue)The text was updated successfully, but these errors were encountered: