MCPcopy Create free account
hub / github.com/bytebase/bytebase / extractIntFromNode

Function extractIntFromNode

backend/plugin/db/pg/query.go:305–317  ·  view source on GitHub ↗

extractIntFromNode extracts an integer value from a LIMIT/OFFSET node.

(node ast.Node)

Source from the content-addressed store, hash-verified

303
304// extractIntFromNode extracts an integer value from a LIMIT/OFFSET node.
305func extractIntFromNode(node ast.Node) int {
306 switch n := node.(type) {
307 case *ast.Integer:
308 return int(n.Ival)
309 case *ast.A_Const:
310 if iv, ok := n.Val.(*ast.Integer); ok {
311 return int(iv.Ival)
312 }
313 return 0
314 default:
315 return 0
316 }
317}
318
319// nodeLocOf returns the Loc of a node, handling common wrapper types.
320func nodeLocOf(node ast.Node) ast.Loc {

Callers 1

rewriteSelectLimitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected