1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-14 02:23:59 +02:00

ON DELETE action for foreign keys in Create table

This commit is contained in:
Jakub Vrana
2010-05-20 22:06:34 +02:00
parent 4c2268d381
commit dc4fc82db8
3 changed files with 20 additions and 16 deletions

View File

@@ -83,7 +83,7 @@ function reEscape(s) {
* @return string
*/
function idfEscape(s) {
return '`' + s.replace(/`/, '``') + '`';
return s.replace(/`/, '``');
}
/** Detect foreign key
@@ -102,14 +102,14 @@ function editingNameChange(field) {
}
var plural = '(?:e?s)?';
var tabCol = table + plural + '_?' + column;
var re = new RegExp('(^' + idfEscape(table + plural) + '\\.' + idfEscape(column) + '$' // table_column
+ '|^' + idfEscape(tabCol) + '\\.' // table
+ '|^' + idfEscape(column + plural) + '\\.' + idfEscape(table) + '$' // column_table
+ ')|\\.' + idfEscape(tabCol) + '$' // column
var re = new RegExp('(^' + idfEscape(table + plural) + '`' + idfEscape(column) + '$' // table_column
+ '|^' + idfEscape(tabCol) + '`' // table
+ '|^' + idfEscape(column + plural) + '`' + idfEscape(table) + '$' // column_table
+ ')|`' + idfEscape(tabCol) + '$' // column
, 'i');
var candidate; // don't select anything with ambiguous match (like column `id`)
for (var i = opts.length; i--; ) {
if (opts[i].value.substr(0, 1) != '`') { // common type
if (!/`/.test(opts[i].value)) { // common type
if (i == opts.length - 2 && candidate && !match[1] && name == 'fields[1]') { // single target table, link to column, first field - probably `id`
return false;
}
@@ -215,6 +215,9 @@ function editingTypeChange(type) {
if (el.name == name + '[unsigned]') {
el.className = (/(int|float|double|decimal)$/.test(text) ? '' : 'hidden');
}
if (el.name == name + '[on_delete]') {
el.className = (/`/.test(text) ? '' : 'hidden');
}
}
}