I’m having a problem with some behavior with the generated code. I’ve got a table, SwitchRule that contains five foreign keys to two other tables, Mode and Dispatch. Everything behaves as expected for four of the columns in the SwitchRule table, selected values persist and are displayed properly. The data shown for one of the columns, however, seems to be the data for a different column. Changes made in the edit screen seem to persist and are visible in the browse screen, but reentering the edit screen shows the previous (incorrect) value, which is then also displayed when returning to the SwitchRule browse screen.
These problems don’t appear when I create versions of the screen with only four of these look-up columns.
To reproduce:
-
create the specified data model on MySQL 5.7.
-
create a new application, click on ‘generate model’, select all three tables, click on ‘run all scripts’, click on ‘localhost:8080/app’ to open the application.
-
create two modes.
-
create three dispatch functions.
-
create a switch rule
-
edit the switch rule - the ‘before dispatch’ value for the created switch rule will contain the same value as the ‘conditional dispatch’ field.
-
return to the switch rule browser
The data model is as follows:
CREATE TABLE `mode` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`index_name` varchar(128) CHARACTER SET utf8 NOT NULL,
`name` varchar(128) NOT NULL,
`stateful_flag` boolean NOT NULL DEFAULT False,
`effective_dt` datetime DEFAULT NULL,
`expiration_dt` datetime NOT NULL DEFAULT '9999-12-31 23:59:59',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_mode_name` (`index_name`,`name`)
);
CREATE TABLE `introspection_dispatch` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(128) DEFAULT NULL,
`category` varchar(128) DEFAULT NULL,
`package_name` varchar(128) DEFAULT NULL,
`module_name` varchar(128) NOT NULL,
`class_name` varchar(128) DEFAULT NULL,
`func_name` varchar(128) DEFAULT NULL,
PRIMARY KEY (`id`)
);
CREATE TABLE `switch_rule` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`index_name` varchar(128) CHARACTER SET utf8 NOT NULL default 'media',
`name` varchar(128) NOT NULL,
`begin_mode_id` int(11) UNSIGNED NOT NULL,
`end_mode_id` int(11) UNSIGNED NOT NULL,
`before_dispatch_id` int(11) UNSIGNED NOT NULL,
`after_dispatch_id` int(11) UNSIGNED NOT NULL,
`condition_dispatch_id` int(11) UNSIGNED,
PRIMARY KEY (`id`),
KEY `fk_switch_rule_begin_mode` (`begin_mode_id`),
CONSTRAINT `c_switch_rule_begin_mode` FOREIGN KEY (`begin_mode_id`) REFERENCES `mode` (`id`),
KEY `fk_switch_rule_end_mode` (`end_mode_id`),
CONSTRAINT `c_switch_rule_end_mode` FOREIGN KEY (`end_mode_id`) REFERENCES `mode` (`id`),
KEY `fk_switch_rule_condition_dispatch` (`condition_dispatch_id`),
CONSTRAINT `c_switch_rule_condition_dispatch` FOREIGN KEY (`condition_dispatch_id`) REFERENCES `introspection_dispatch` (`id`),
KEY `fk_switch_rule_before_dispatch` (`before_dispatch_id`),
CONSTRAINT `c_switch_rule_before_dispatch` FOREIGN KEY (`before_dispatch_id`) REFERENCES `introspection_dispatch` (`id`),
KEY `fk_switch_rule_after_dispatch` (`after_dispatch_id`),
CONSTRAINT `c_switch_rule_after_dispatch` FOREIGN KEY (`after_dispatch_id`) REFERENCES `introspection_dispatch` (`id`),
UNIQUE KEY `uk_switch_rule_name` (`index_name`,`name`));
sample data:
INSERT INTO mode (index_name,name, effective_dt) VALUES ('media', 'analyze', now());
INSERT INTO mode (index_name,name, effective_dt) VALUES ('media', 'sync', now());
INSERT INTO mode (index_name,name, effective_dt) VALUES ('media', 'report', now());
INSERT INTO introspection_dispatch (name, category, module_name, class_name, func_name) VALUES ('analyze.switch.after', 'switch', 'docserv', 'AnalyzeModeHandler', 'after_analyze');
INSERT INTO introspection_dispatch (name, category, module_name, class_name, func_name) VALUES ('report.switch.before', 'switch', 'docserv', 'DocumentServiceProcessHandler', 'before');
INSERT INTO introspection_dispatch (name, category, module_name, class_name, func_name) VALUES ('report.switch.after', 'switch', 'docserv', 'DocumentServiceProcessHandler', 'after');
extraneous - the business purpose of this screen is to configure a data-based run-time engine that cycles through a set of modes, each with conditional, pre, post and effect functions and an associated code-generator used to create the boilerplate for these modes.