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

Draft: fix float precision issue (double.valueOf float gives precision issues) #873

Open
wants to merge 1 commit 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
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,30 @@ public void testExecuteInDb_H2()
compileAndExecute("test():Any[0..1]");
}

@Test
public void testInsertFloatInDb_H2()
{
compileTestSource(
TEST_SOURCE_ID,
"import meta::external::store::relational::runtime::*;\n" +
"import meta::relational::metamodel::*;\n" +
"import meta::relational::metamodel::execute::*;\n" +
"import meta::relational::functions::toDDL::*;\n" +
"function test():Any[0..1]\n" +
"{\n" +
" let dbConnection = ^TestDatabaseConnection(type = meta::relational::runtime::DatabaseType.H2);\n" +
" executeInDb('drop table myTable IF EXISTS;', $dbConnection, 0, 1000);\n" +
" executeInDb('create table myTable(col1 FLOAT)', $dbConnection, 0, 1000);\n" +
" executeInDb('insert into myTable(col1) values (0.9)', $dbConnection, 0, 1000);\n" +
" let res = executeInDb('select * from myTable', $dbConnection, 0, 1000);\n" +
" assertEquals(0.9 , $res.rows.values);\n" +
"}\n" +
"###Relational\n" +
"Database mydb()\n"
);
compileAndExecute("test():Any[0..1]");
}

@Test
public void testExecuteInb_DuckDB()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Object value(ResultSet rs, int i, CoreInstance nullSqlInstance, Calendar
public Object value(ResultSet rs, int i, CoreInstance nullSqlInstance, Calendar calendar) throws SQLException
{
float f = rs.getFloat(i);
return rs.wasNull() ? nullSqlInstance : Double.valueOf(f);
return rs.wasNull() ? nullSqlInstance : f;
}
};

Expand Down
Loading