-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1cca1f0
commit eb4eb56
Showing
11 changed files
with
229 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { OperationNode } from './operation-node.js' | ||
import { ValueNode } from './value-node.js' | ||
|
||
export type FetchModifier = 'only' | 'with ties' | ||
|
||
export interface FetchNode extends OperationNode { | ||
readonly kind: 'FetchNode' | ||
readonly rowCount: ValueNode | ||
readonly modifier: FetchModifier | ||
} | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const FetchNode = { | ||
is(node: OperationNode): node is FetchNode { | ||
return node.kind === 'FetchNode' | ||
}, | ||
|
||
create(rowCount: number | bigint, modifier: FetchModifier): FetchNode { | ||
return { | ||
kind: 'FetchNode', | ||
rowCount: ValueNode.create(rowCount), | ||
modifier, | ||
} | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { FetchModifier, FetchNode } from '../operation-node/fetch-node.js' | ||
import { isBigInt, isNumber } from '../util/object-utils.js' | ||
|
||
export function parseFetch( | ||
rowCount: number | bigint, | ||
modifier: FetchModifier, | ||
): FetchNode { | ||
if (!isNumber(rowCount) && !isBigInt(rowCount)) { | ||
throw new Error(`Invalid fetch row count: ${rowCount}`) | ||
} | ||
|
||
if (!isFetchModifier(modifier)) { | ||
throw new Error(`Invalid fetch modifier: ${modifier}`) | ||
} | ||
|
||
return FetchNode.create(rowCount, modifier) | ||
} | ||
|
||
function isFetchModifier(value: any): value is FetchModifier { | ||
return value === 'only' || value === 'with ties' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.