mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-23 11:36:01 +00:00
select page by row_number for MS SQL 2008 #93
This commit is contained in:
@@ -62,5 +62,12 @@ export function dumpSqlCondition(dmp: SqlDumper, condition: Condition) {
|
||||
dumpSqlSelect(dmp, condition.subQuery);
|
||||
dmp.put(')');
|
||||
break;
|
||||
case 'between':
|
||||
dumpSqlExpression(dmp, condition.expr);
|
||||
dmp.put(' ^between ');
|
||||
dumpSqlExpression(dmp, condition.left);
|
||||
dmp.put(' ^and ');
|
||||
dumpSqlExpression(dmp, condition.right);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,5 +38,14 @@ export function dumpSqlExpression(dmp: SqlDumper, expr: Expression) {
|
||||
case 'transform':
|
||||
dmp.transform(expr.transform, () => dumpSqlExpression(dmp, expr.expr));
|
||||
break;
|
||||
|
||||
case 'rowNumber':
|
||||
dmp.put(" ^row_number() ^over (^order ^by ");
|
||||
dmp.putCollection(', ', expr.orderBy, x => {
|
||||
dumpSqlExpression(dmp, x);
|
||||
dmp.put(' %k', x.direction);
|
||||
});
|
||||
dmp.put(")");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,13 @@ export interface NotExistsCondition {
|
||||
subQuery: Select;
|
||||
}
|
||||
|
||||
export interface BetweenCondition {
|
||||
conditionType: 'between';
|
||||
expr: Expression;
|
||||
left: Expression;
|
||||
right: Expression;
|
||||
}
|
||||
|
||||
export type Condition =
|
||||
| BinaryCondition
|
||||
| NotCondition
|
||||
@@ -99,7 +106,8 @@ export type Condition =
|
||||
| CompoudCondition
|
||||
| LikeCondition
|
||||
| ExistsCondition
|
||||
| NotExistsCondition;
|
||||
| NotExistsCondition
|
||||
| BetweenCondition;
|
||||
|
||||
export interface Source {
|
||||
name?: NamedObjectInfo;
|
||||
@@ -153,13 +161,19 @@ export interface TranformExpression {
|
||||
transform: TransformType;
|
||||
}
|
||||
|
||||
export interface RowNumberExpression {
|
||||
exprType: 'rowNumber';
|
||||
orderBy: OrderByExpression[];
|
||||
}
|
||||
|
||||
export type Expression =
|
||||
| ColumnRefExpression
|
||||
| ValueExpression
|
||||
| PlaceholderExpression
|
||||
| RawExpression
|
||||
| CallExpression
|
||||
| TranformExpression;
|
||||
| TranformExpression
|
||||
| RowNumberExpression;
|
||||
export type OrderByExpression = Expression & { direction: 'ASC' | 'DESC' };
|
||||
|
||||
export type ResultField = Expression & { alias?: string };
|
||||
|
||||
Reference in New Issue
Block a user