Permalink
Browse files

Support camelCase in automatic foreign keys

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@779 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent ced9de9 commit 33f43a6ef0cc8a42ecde49824d2baae4438f9d36 jakubvrana committed Jul 2, 2009
Showing with 6 additions and 5 deletions.
  1. +4 −3 adminer/functions.js
  2. +2 −2 adminer/include/editing.inc.php
@@ -80,7 +80,7 @@ function editing_name_change(field) {
var table = re_escape(field.value);
var column = '';
var match;
- if (match = /(.+)_(.+)/.exec(table)) { // limited to columns not containing underscores
+ if ((match = /(.+)_(.+)/.exec(table)) || (match = /(.*[a-z])([A-Z].*)/.exec(table))) { // limited to single word columns
table = match[1];
column = match[2];
}
@@ -151,13 +151,14 @@ function editing_remove_row(button) {
function editing_type_change(type) {
var name = type.name.substr(0, type.name.length - 6);
+ var text = type.options[type.selectedIndex].text;
for (var i=0; i < type.form.elements.length; i++) {
var el = type.form.elements[i];
if (el.name == name + '[collation]') {
- el.className = (/char|text|enum|set/.test(type.options[type.selectedIndex].text) ? '' : 'hidden');
+ el.className = (/(char|text|enum|set)$/.test(text) ? '' : 'hidden');
}
if (el.name == name + '[unsigned]') {
- el.className = (/int|float|double|decimal/.test(type.options[type.selectedIndex].text) ? '' : 'hidden');
+ el.className = (/(int|float|double|decimal)$/.test(text) ? '' : 'hidden');
}
}
}
@@ -123,8 +123,8 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
<td><select name="<?php echo $key; ?>[type]" onchange="editing_type_change(this);"><?php echo optionlist(array_keys($types) + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select></td>
<td><input name="<?php echo $key; ?>[length]" value="<?php echo htmlspecialchars($field["length"]); ?>" size="3" /></td>
<td><?php
-echo "<select name=\"$key" . '[collation]"' . (ereg('~(char|text|enum|set)$~', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')</option>' . optionlist($collations, $field["collation"]) . '</select>';
-echo ($unsigned ? " <select name=\"$key" . '[unsigned]"' . (!$field["type"] || ereg('~(int|float|double|decimal)$~', $field["type"]) ? "" : " class='hidden'") . '><option></option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
+echo "<select name=\"$key" . '[collation]"' . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')</option>' . optionlist($collations, $field["collation"]) . '</select>';
+echo ($unsigned ? " <select name=\"$key" . '[unsigned]"' . (!$field["type"] || ereg('(int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option></option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
?></td>
<?php
}

0 comments on commit 33f43a6

Please sign in to comment.