mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-08 22:12:29 +08:00
Compare commits
15 Commits
fix/oceanb
...
fix/oceanb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5712b39cf9 | ||
|
|
07dc1436af | ||
|
|
20ff4f3687 | ||
|
|
73ce3039ce | ||
|
|
61296bc855 | ||
|
|
78da0076cf | ||
|
|
279b38fec3 | ||
|
|
0e348fcca4 | ||
|
|
7d79fae84d | ||
|
|
f642e0325d | ||
|
|
43a408f1c9 | ||
|
|
b97b5cf6e2 | ||
|
|
6c269a99cf | ||
|
|
24841f2dd9 | ||
|
|
c2e60c1e52 |
@@ -126,10 +126,11 @@ const installOceanBaseOracleNavigationFallback = (editor: any) => {
|
||||
}
|
||||
|
||||
const parts = splitSqlIdentifierPath(identifier.text);
|
||||
if (parts.length !== 2) {
|
||||
if (parts.length < 2) {
|
||||
return;
|
||||
}
|
||||
const [schemaName, tableName] = parts;
|
||||
const schemaName = parts[parts.length - 2];
|
||||
const tableName = parts[parts.length - 1];
|
||||
if (!schemaName || !tableName) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ const legacyLiterals = [
|
||||
'选择连接',
|
||||
'选择数据库',
|
||||
'最大返回行数',
|
||||
'最大行数:100',
|
||||
'最大行数:500',
|
||||
'最大行数:1000',
|
||||
'最大行数:5000',
|
||||
@@ -64,6 +65,7 @@ describe('QueryEditorToolbar i18n', () => {
|
||||
expect(source).toContain("import { useOptionalI18n } from '../i18n/provider';");
|
||||
expect(source).toContain('const i18n = useOptionalI18n();');
|
||||
expect(source).toContain('const t = i18n?.t ?? defaultTranslate;');
|
||||
expect(source).toContain("{ label: '100', value: 100 }");
|
||||
|
||||
for (const key of requiredKeys) {
|
||||
expect(source).toContain(key);
|
||||
|
||||
@@ -291,6 +291,7 @@ const QueryEditorToolbar: React.FC<QueryEditorToolbarProps> = ({
|
||||
value={maxRows}
|
||||
onChange={(val) => onMaxRowsChange(Number(val))}
|
||||
options={[
|
||||
{ label: '100', value: 100 },
|
||||
{ label: t("query_editor.max_rows.option_500"), value: 500 },
|
||||
{ label: t("query_editor.max_rows.option_1000"), value: 1000 },
|
||||
{ label: t("query_editor.max_rows.option_5000"), value: 5000 },
|
||||
|
||||
@@ -40,9 +40,9 @@ describe('applyQueryAutoLimit', () => {
|
||||
['dameng'],
|
||||
['dm'],
|
||||
['dm8'],
|
||||
])('adds ROWNUM limit for %s connections', (dbType) => {
|
||||
])('adds FETCH FIRST limit for %s connections', (dbType) => {
|
||||
expect(applyQueryAutoLimit('SELECT * FROM MYCIMLED.EDC_LOG', dbType, 500).sql)
|
||||
.toBe('SELECT * FROM (SELECT * FROM MYCIMLED.EDC_LOG) WHERE ROWNUM <= 500');
|
||||
.toBe('SELECT * FROM MYCIMLED.EDC_LOG FETCH FIRST 500 ROWS ONLY');
|
||||
});
|
||||
|
||||
it.each([
|
||||
@@ -61,8 +61,8 @@ describe('applyQueryAutoLimit', () => {
|
||||
});
|
||||
|
||||
it.each([
|
||||
['oracle', 'SELECT * FROM (SELECT * FROM users) WHERE ROWNUM <= 500'],
|
||||
['dm8', 'SELECT * FROM (SELECT * FROM users) WHERE ROWNUM <= 500'],
|
||||
['oracle', 'SELECT * FROM users FETCH FIRST 500 ROWS ONLY'],
|
||||
['dm8', 'SELECT * FROM users FETCH FIRST 500 ROWS ONLY'],
|
||||
['mssql', 'SELECT TOP 500 * FROM users'],
|
||||
['postgresql', 'SELECT * FROM users LIMIT 500'],
|
||||
['gauss-db', 'SELECT * FROM users LIMIT 500'],
|
||||
@@ -76,12 +76,17 @@ describe('applyQueryAutoLimit', () => {
|
||||
|
||||
it('keeps trailing semicolon and comments after injected Oracle limit', () => {
|
||||
expect(applyQueryAutoLimit('SELECT * FROM MYCIMLED.EDC_LOG; -- preview', 'oracle', 500).sql)
|
||||
.toBe('SELECT * FROM (SELECT * FROM MYCIMLED.EDC_LOG) WHERE ROWNUM <= 500; -- preview');
|
||||
.toBe('SELECT * FROM MYCIMLED.EDC_LOG FETCH FIRST 500 ROWS ONLY; -- preview');
|
||||
});
|
||||
|
||||
it('uses Oracle 11g compatible ROWNUM limit for simple table queries', () => {
|
||||
it('uses Oracle FETCH FIRST limit for simple table queries', () => {
|
||||
expect(applyQueryAutoLimit('select 1 from xxx', 'oracle', 500).sql)
|
||||
.toBe('SELECT * FROM (select 1 from xxx) WHERE ROWNUM <= 500');
|
||||
.toBe('select 1 from xxx FETCH FIRST 500 ROWS ONLY');
|
||||
});
|
||||
|
||||
it('keeps ORDER BY semantics with Oracle FETCH FIRST', () => {
|
||||
expect(applyQueryAutoLimit('SELECT * FROM users ORDER BY created_at DESC', 'oracle', 100).sql)
|
||||
.toBe('SELECT * FROM users ORDER BY created_at DESC FETCH FIRST 100 ROWS ONLY');
|
||||
});
|
||||
|
||||
it('does not add another generic limit when SQL already limits rows', () => {
|
||||
|
||||
@@ -322,7 +322,7 @@ export const applyQueryAutoLimit = (
|
||||
if (offsetPos >= 0 && (fromPos < 0 || offsetPos > fromPos)) return { sql, applied: false, maxRows };
|
||||
const forPos = findTopLevelKeyword(main, 'for');
|
||||
if (forPos >= 0 && (fromPos < 0 || forPos > fromPos)) return { sql, applied: false, maxRows };
|
||||
return { sql: `SELECT * FROM (${main.trimEnd()}) WHERE ROWNUM <= ${maxRows}${tail}`, applied: true, maxRows };
|
||||
return { sql: `${main.trimEnd()} FETCH FIRST ${maxRows} ROWS ONLY${tail}`, applied: true, maxRows };
|
||||
}
|
||||
|
||||
const offsetPos = findTopLevelKeyword(main, 'offset');
|
||||
|
||||
Reference in New Issue
Block a user