Letractively / activeweb

Automatically exported from code.google.com/p/activeweb
0 stars 0 forks source link

AJ doesn't compose a correct SQL statement for a model when we save it. It does include all the columns it have in metadata, but it should not do that. #93

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Here is an example.

I have a table in the database with the next structure:
Table user:
ID number,
NAME string, 
AGE number,
REGISTRATION_DATE date default currDate.

I.e. column registration_date should be populated by DB server if it is missing 
in insert statement, but insert statement WILL ALWAYS CONTAIN ALL THE COLUMNS 
from the metamodel, not only columns I fill out before insert.

User user = new User();
user.setString("name", "John Smith");
user.setAge(new Integer(17));
user.save();

So, after running that code I expect that column registration_date will be 
updated by DB server to the currect date, but it won't be, because AJ does 
force updating that columns with a null value - i.e. SQL will be like that:
insert into user (ID, NAME, AGE, REGISTRATION_DATE) values (12345, "John 
Smith", 17, NULL) - i.e. default value defined in table structure will be 
working.

According to Model.java we should build at SQL based on the attributes map, not 
on the list of sttribued returned by metamodel, line 1973.

Thanks,
Dima

Original issue reported on code.google.com by zbd...@gmail.com on 2 Apr 2012 at 7:46

GoogleCodeExporter commented 9 years ago
moved under AJ project

Original comment by zbd...@gmail.com on 2 Apr 2012 at 7:55

GoogleCodeExporter commented 9 years ago
this was entered here by mistake, was already fixed in ActiveJDBC

Original comment by ipolevoy@gmail.com on 6 Apr 2012 at 4:32