- Timestamp:
- 07/08/09 20:56:36 (8 months ago)
- Files:
-
- fSchema.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
fSchema.php
r610 r634 Hide Line Numbers 10 10 * @link http://flourishlib.com/fSchema 11 11 * 12 * @version 1.0.0b21 12 * @version 1.0.0b22 13 * @changes 1.0.0b22 PostgreSQL UNIQUE constraints that are created as indexes and not table constraints are now properly detected [wb, 2009-07-08] 13 14 * @changes 1.0.0b21 Added support for the UUID data type in PostgreSQL [wb, 2009-06-18] 14 15 * @changes 1.0.0b20 Add caching of merged info, improved performance of ::getColumnInfo() [wb, 2009-06-15] … … 1304 1305 } 1305 1306 1306 $sql = "SELECT 1307 $sql = "( 1308 SELECT 1307 1309 t.relname AS table, 1308 1310 con.conname AS constraint_name, … … 1328 1330 WHEN 'n' THEN 'set_null' 1329 1331 WHEN 'd' THEN 'set_default' 1330 END AS on_update 1332 END AS on_update, 1333 CASE WHEN con.conkey IS NOT NULL THEN position('-'||col.attnum||'-' in '-'||array_to_string(con.conkey, '-')||'-') ELSE 0 END AS column_order 1331 1334 FROM 1332 1335 pg_attribute AS col INNER JOIN … … 1342 1345 con.contype = 'f' OR 1343 1346 con.contype = 'u') 1344 ORDER BY 1345 t.relname, 1346 con.contype, 1347 con.conname, 1348 CASE WHEN con.conkey IS NOT NULL THEN position('-'||col.attnum||'-' in '-'||array_to_string(con.conkey, '-')||'-') ELSE 0 END, 1349 col.attname"; 1347 ) UNION ( 1348 SELECT 1349 t.relname AS table, 1350 ic.relname AS constraint_name, 1351 'unique' AS type, 1352 col.attname AS column, 1353 NULL AS foreign_table, 1354 NULL AS foreign_column, 1355 NULL AS on_delete, 1356 NULL AS on_update, 1357 CASE WHEN ind.indkey IS NOT NULL THEN position('-'||col.attnum||'-' in '-'||array_to_string(ind.indkey, '-')||'-') ELSE 0 END AS column_order 1358 FROM 1359 pg_class AS t INNER JOIN 1360 pg_index AS ind ON ind.indrelid = t.oid INNER JOIN 1361 pg_namespace AS n ON t.relnamespace = n.oid INNER JOIN 1362 pg_class AS ic ON ind.indexrelid = ic.oid LEFT JOIN 1363 pg_constraint AS con ON con.conrelid = t.oid AND con.contype = 'u' AND con.conname = ic.relname INNER JOIN 1364 pg_attribute AS col ON col.attrelid = t.oid AND col.attnum = ANY (ind.indkey) 1365 WHERE 1366 n.nspname NOT IN ('pg_catalog', 'pg_toast') AND 1367 indisunique = TRUE AND 1368 indisprimary = FALSE AND 1369 con.oid IS NULL 1370 ) ORDER BY 1, 3, 2, 9"; 1350 1371 1351 1372 $result = $this->database->query($sql);
