scaffolder has a problem with capitalisation in field names
Expected and Actual Behavior
Trying to scaffold a database table with Capital letters in the field names and use the resultant CRUD
The tables scaffolds without error but the resultant code has issues.
If I use --get-set then createAction() and saveAction() set all field values in the DB to null. If I don't use --get-set when scaffolding then createAction and saveAction has no effect on existing data.
Altering my mysql create table statements so that all fieldnames are lowercase only resolves the issue.
Thanks,
Eoin
OS Windows 10 Phalcon Version 3.3.1 Devtools Version 3.2.12 PHP version 7,2
I went back and checked and this problem seems to start in dev-tools v3.2.3. v3.2.2 doesn't handle --get-set at all. But 3.20 is fine and doesn't have the issue with upper-case in field names. v3.2.0 doesn't have the issue. The issue persists in v3.2.12. Hope this helps
I do think this qualifies as a bug though.
@eokenned Thank you for report. Could you provide a bit more information? I'd like to have to take a look your configuration, your data that you have at the start and the end. Steps to reproduce would very helpful.
Sorry for the delay in responding. Here are some steps to recreate the issue.
- Create the following data and associated rows of data - Note the upper case at the start of the field names
Create table Member(
ID integer auto_increment,
Firstname Varchar(30),
Surname Varchar(30),
Membertype Varchar(6),
Dateofbirth date,
Primary Key(id)
);
INSERT INTO Member (Firstname,Surname,MemberType,DateOfBirth) VALUES ('Oliver','Kerr','Senior','2000-01-31');
INSERT INTO Member (Firstname,Surname,MemberType,DateOfBirth) VALUES ('Morgan','Bartlett','Senior','1985-10-28');
- scaffold the table using
phalcon scaffold member --get-set
-
vist the
/member/edit/1of the resulting scaffolded app -
Edit the members details - make a modification
-
Save the modification
-
Note the message "member has been updated successfully"
-
Query the member table in the database
-
Note how all the member's details for the member you have just updated have been set to null
If you change the field names in the member table to all lower case and repeat the steps the problem goes away.
@eokenned Could you provide your controller and model?
Fixed