Loris icon indicating copy to clipboard operation
Loris copied to clipboard

[tools] `generate_tables_sql.php` generates broken SQL

Open maximemulder opened this issue 7 months ago • 0 comments

Describe the bug

While trying to add an instrument to my dev VM, I encountered a bug in which the SQL generated by generate_tables_sql.php is syntactically broken. I believe this is a regression introduced in #8674, see the results bellow.

Expected output:

CREATE TABLE `SYNHOME_Montreal_Cognitive_Assessment` (
                `CommentID` varchar(255) NOT NULL default '',
                `UserID` varchar(255) default NULL,
                `Examiner` varchar(255) default NULL,
                `Testdate` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`Date_taken` date default NULL,
`Candidate_Age` varchar(255) default NULL,
`Window_Difference` varchar(255) default NULL,
PRIMARY KEY  (`CommentID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Actual output:

`SYNHOME_Montreal_Cognitive_Assessment` testname default NULL,
CREATE TABLE `SYNHOME_Montreal_Cognitive_Assessment` (
                `CommentID` varchar(255) NOT NULL default '',
                `UserID` varchar(255) default NULL,
                `Examiner` varchar(255) default NULL,
                `Testdate` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`Date_taken` date default NULL,
`Candidate_Age` varchar(255) default NULL,
`Window_Difference` varchar(255) default NULL,
PRIMARY KEY  (`CommentID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

The error is obviously in the first line. PR coming soon.

maximemulder avatar Jul 25 '24 15:07 maximemulder