jan-vandenberg / cruddiy

No-code Bootstrap PHP CRUD generator
http://cruddiy.com
GNU Affero General Public License v3.0
253 stars 80 forks source link

Pre-defined relations appear twice on relations.php #87

Closed germain-italic closed 12 months ago

germain-italic commented 12 months ago

Given the following schema

DROP TABLE IF EXISTS `products`;
CREATE TABLE `products` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `ean` varchar(13) NOT NULL,
  `product_name` varchar(255) DEFAULT NULL,
  `brand_id` int(11) DEFAULT NULL,
  `supplier_id` int(11) DEFAULT NULL,
  `visual_url` text,
  `packaging_details` text,
  `recycled_material_incorporation` decimal(5,2) DEFAULT NULL,
  `hazardous_substance_presence` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ean` (`ean`),
  KEY `supplier_id` (`supplier_id`),
  KEY `product_data_ibfk_1` (`brand_id`),
  CONSTRAINT `products_ibfk_1` FOREIGN KEY (`brand_id`) REFERENCES `brands` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

The generated query on relations.php will be:

SELECT i.TABLE_NAME as 'Table Name', k.COLUMN_NAME as 'Foreign Key', k.REFERENCED_TABLE_NAME as 'Primary Table', k.REFERENCED_COLUMN_NAME as 'Primary Key', i.CONSTRAINT_NAME as 'Constraint Name', 'Delete' as 'Delete' FROM information_schema.TABLE_CONSTRAINTS i LEFT JOIN information_schema.KEY_COLUMN_USAGE k ON i.CONSTRAINT_NAME = k.CONSTRAINT_NAME WHERE i.CONSTRAINT_TYPE = 'FOREIGN KEY' AND i.TABLE_SCHEMA = DATABASE()

It displays the relation twice:

I'm working on it.