phalcon-devtools icon indicating copy to clipboard operation
phalcon-devtools copied to clipboard

scaffolder has a problem with capitalisation in field names

Open eokenned opened this issue 8 years ago • 6 comments

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

eokenned avatar Jan 25 '18 14:01 eokenned

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

eokenned avatar Feb 16 '18 17:02 eokenned

I do think this qualifies as a bug though.

eokenned avatar Feb 16 '18 17:02 eokenned

@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.

sergeysviridenko avatar Feb 16 '18 18:02 sergeysviridenko

Sorry for the delay in responding. Here are some steps to recreate the issue.

  1. 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');
  1. scaffold the table using
phalcon scaffold member --get-set
  1. vist the /member/edit/1 of the resulting scaffolded app

  2. Edit the members details - make a modification

  3. Save the modification

  4. Note the message "member has been updated successfully"

  5. Query the member table in the database

  6. 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 avatar Feb 21 '18 14:02 eokenned

@eokenned Could you provide your controller and model?

sergeysviridenko avatar Apr 02 '18 09:04 sergeysviridenko

Fixed

Jeckerson avatar May 20 '19 14:05 Jeckerson