ITADN

Missing "distinct" when obtaining relationships for db schema in postgres (eg partitioned tables)

#544Closeddam2k 创建于 2026-04-13
D
dam2kcommented
**Describe the bug** On partitioned tables, the missing "distinct" on the select in PGSQLSchemaTool::getRelationships() will generate tons and tons of identical foreign keys saturating the LLM with garbage. **To Reproduce** Steps to reproduce the behavior: Create partitioned tables and use the PGSQLSchemaTool **Expected behavior** The expected behavior is a clean understanding of the DB relationships **Screenshots** nope **The Neuron AI version you are using:** - Version 3.3.5 **Additional context** Adding "distinct" to the query solve the issue in case of partitioned tables: 231 $stmt = $this->pdo->prepare(" 232 SELECT 233 **DISTINCT** tc.constraint_name, 234 tc.table_name as source_table, 235 kcu.column_name as source_column, 236 ccu.table_name as target_table, 237 ccu.column_name as target_column, 238 rc.update_rule, 239 rc.delete_rule 240 FROM information_schema.table_constraints tc 241 JOIN information_schema.key_column_usage kcu 242 ON tc.constraint_name = kcu.constraint_name 243 AND tc.table_schema = kcu.table_schema 244 JOIN information_schema.constraint_column_usage ccu 245 ON ccu.constraint_name = tc.constraint_name 246 AND ccu.table_schema = tc.table_schema 247 JOIN information_schema.referential_constraints rc 248 ON tc.constraint_name = rc.constraint_name 249 AND tc.table_schema = rc.constraint_schema 250 $whereClause 251 AND tc.constraint_type = 'FOREIGN KEY' 252 ORDER BY tc.table_name 253 ");
关闭于 2026-04-14 1 条评论