mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-11 23:42:22 +08:00
Compare commits
11 Commits
fix/update
...
fix/oceanb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c27a038fc5 | ||
|
|
c3c4efc6ec | ||
|
|
7a87d43bdc | ||
|
|
5fa1c90674 | ||
|
|
c79225ef27 | ||
|
|
0bd8fdea1f | ||
|
|
18dbd043ae | ||
|
|
a7535dec2b | ||
|
|
dbd4b7f763 | ||
|
|
68eacbbcf7 | ||
|
|
a4a0ac25cf |
@@ -26,6 +26,25 @@ describe('queryResultPagination', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('treats query-editor injected LIMIT as a capped page rather than an uncounted total', () => {
|
||||||
|
const page = createInitialQueryResultPagination({
|
||||||
|
executedSql: 'SELECT id, name FROM users LIMIT 500',
|
||||||
|
exportSql: 'SELECT id, name FROM users',
|
||||||
|
dbType: 'mysql',
|
||||||
|
returnedRowCount: 500,
|
||||||
|
fallbackPageSize: 500,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(page).toMatchObject({
|
||||||
|
current: 1,
|
||||||
|
pageSize: 500,
|
||||||
|
total: 500,
|
||||||
|
totalKnown: true,
|
||||||
|
baseSql: 'SELECT id, name FROM users',
|
||||||
|
exportAllSql: 'SELECT id, name FROM users',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('builds the next page SQL with one lookahead row', () => {
|
it('builds the next page SQL with one lookahead row', () => {
|
||||||
expect(buildQueryResultPageSql({
|
expect(buildQueryResultPageSql({
|
||||||
baseSql: 'SELECT id FROM users',
|
baseSql: 'SELECT id FROM users',
|
||||||
|
|||||||
@@ -22,6 +22,14 @@ const normalizePositiveInteger = (value: unknown): number => {
|
|||||||
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const normalizeSqlForComparison = (sql: string): string => (
|
||||||
|
String(sql || '')
|
||||||
|
.replace(/\s+/g, ' ')
|
||||||
|
.replace(/;+\s*$/g, '')
|
||||||
|
.trim()
|
||||||
|
.toLowerCase()
|
||||||
|
);
|
||||||
|
|
||||||
const parseTopLevelLimit = (sql: string): LimitInfo | null => {
|
const parseTopLevelLimit = (sql: string): LimitInfo | null => {
|
||||||
const { main } = splitSqlTail(sql);
|
const { main } = splitSqlTail(sql);
|
||||||
const limitPos = findTopLevelKeyword(main, 'limit');
|
const limitPos = findTopLevelKeyword(main, 'limit');
|
||||||
@@ -60,6 +68,14 @@ const stripExplicitLimitForExport = (sql: string): string => {
|
|||||||
return splitSqlTail(sql).main.trim();
|
return splitSqlTail(sql).main.trim();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const wasLimitAppliedByQueryEditorCap = (executedSql: string, exportSql: string): boolean => {
|
||||||
|
const executed = String(executedSql || '').trim();
|
||||||
|
const exportable = String(exportSql || '').trim();
|
||||||
|
if (!executed || !exportable) return false;
|
||||||
|
if (normalizeSqlForComparison(executed) === normalizeSqlForComparison(exportable)) return false;
|
||||||
|
return normalizeSqlForComparison(stripExplicitLimitForExport(executed)) === normalizeSqlForComparison(stripExplicitLimitForExport(exportable));
|
||||||
|
};
|
||||||
|
|
||||||
const resolveWrappedBaseSql = (dbType: string, baseSql: string): string => {
|
const resolveWrappedBaseSql = (dbType: string, baseSql: string): string => {
|
||||||
const normalizedType = String(dbType || '').trim().toLowerCase();
|
const normalizedType = String(dbType || '').trim().toLowerCase();
|
||||||
const base = baseSql.trim();
|
const base = baseSql.trim();
|
||||||
@@ -146,7 +162,10 @@ export const createInitialQueryResultPagination = (params: {
|
|||||||
const exportAllSql = exportSql && getLeadingKeyword(exportSql) === 'select'
|
const exportAllSql = exportSql && getLeadingKeyword(exportSql) === 'select'
|
||||||
? stripExplicitLimitForExport(exportSql)
|
? stripExplicitLimitForExport(exportSql)
|
||||||
: stripExplicitLimitForExport(executedSql);
|
: stripExplicitLimitForExport(executedSql);
|
||||||
const totalState = resolveQueryResultPaginationTotal({
|
const autoLimitCap = current === 1 && wasLimitAppliedByQueryEditorCap(executedSql, exportSql);
|
||||||
|
const totalState = autoLimitCap
|
||||||
|
? { total: returnedRowCount, totalKnown: true }
|
||||||
|
: resolveQueryResultPaginationTotal({
|
||||||
current,
|
current,
|
||||||
pageSize,
|
pageSize,
|
||||||
rowCount: returnedRowCount,
|
rowCount: returnedRowCount,
|
||||||
|
|||||||
@@ -93,9 +93,9 @@ func resolveWindowsUpdateFinalTargetPath(currentTarget string, sourcePath string
|
|||||||
func isVersionedWindowsUpdatePackageName(name string) bool {
|
func isVersionedWindowsUpdatePackageName(name string) bool {
|
||||||
trimmed := strings.TrimSpace(name)
|
trimmed := strings.TrimSpace(name)
|
||||||
lower := strings.ToLower(trimmed)
|
lower := strings.ToLower(trimmed)
|
||||||
return strings.HasPrefix(trimmed, "GoNavi-")
|
return strings.HasPrefix(trimmed, "GoNavi-") &&
|
||||||
&& strings.Contains(trimmed, "-Windows-")
|
strings.Contains(trimmed, "-Windows-") &&
|
||||||
&& strings.HasSuffix(lower, ".exe")
|
strings.HasSuffix(lower, ".exe")
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareWindowsStagedUpdateAsset(sourcePath string, stagedDir string) (string, error) {
|
func prepareWindowsStagedUpdateAsset(sourcePath string, stagedDir string) (string, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user