-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_autocomplete_debug.html
More file actions
78 lines (68 loc) · 2.95 KB
/
test_autocomplete_debug.html
File metadata and controls
78 lines (68 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html>
<head>
<title>Autocomplete Test</title>
<script>
function testColumnAutocomplete() {
// Teste die verschiedenen Funktionen
console.log('Testing extractTableNameFromQuery...');
// Test-Queries
const testQueries = [
'SELECT * FROM AUTH_CONFIG',
'SELECT NAME FROM AUTH_CONFIG WHERE',
'select id, name from AUTH_CONFIG',
'SELECT COUNT(*) FROM AUTH_CONFIG',
'SELECT * FROM AUTH_CONFIG ORDER BY'
];
testQueries.forEach(query => {
console.log(`Query: "${query}"`);
// Simuliere extractTableNameFromQuery
const upperText = query.toUpperCase();
const patterns = [
/\bFROM\s+([A-Z_][A-Z0-9_]*)/,
/\bFROM\s+([A-Z_][A-Z0-9_]*)\s+[A-Z_]/,
/\bFROM\s+([A-Z_][A-Z0-9_]*)\s*,/,
/\bFROM\s+([A-Z_][A-Z0-9_]*)\s*$/,
/\bFROM\s+([A-Z_][A-Z0-9_]*)\s+WHERE/,
/\bFROM\s+([A-Z_][A-Z0-9_]*)\s+ORDER/,
/\bFROM\s+([A-Z_][A-Z0-9_]*)\s+GROUP/
];
let found = false;
for (const pattern of patterns) {
const match = upperText.match(pattern);
if (match && match[1]) {
console.log(` Found table: ${match[1]} with pattern: ${pattern}`);
found = true;
break;
}
}
if (!found) {
console.log(' No table found');
}
// Teste shouldShowColumnAutocomplete
const textBeforeCursor = query.toUpperCase();
const hasFromClause = /\bFROM\s+[A-Z_][A-Z0-9_]*/.test(textBeforeCursor);
console.log(` Has FROM clause: ${hasFromClause}`);
const selectPatterns = [
/\bSELECT\s*$/,
/\bSELECT\s+((?:[A-Z_0-9*]+(?:\s*,\s*)?)*)\s*([A-Z_0-9]*)$/,
/\bSELECT\s+[^,]+(?:\s*,\s*[^,]*)*\s*,\s*([A-Z_0-9]*)$/
];
selectPatterns.forEach((pattern, index) => {
if (pattern.test(textBeforeCursor)) {
console.log(` SELECT pattern ${index} matched`);
}
});
console.log('---');
});
}
// Teste beim Laden der Seite
window.onload = testColumnAutocomplete;
</script>
</head>
<body>
<h1>Autocomplete Debug Test</h1>
<p>Öffne die Browser-Konsole um die Test-Ergebnisse zu sehen.</p>
<p>Teste dann in der echten Anwendung: "SELECT " gefolgt von "FROM AUTH_CONFIG"</p>
</body>
</html>