MCPcopy Create free account
hub / github.com/LissaGreense/GO4SQL / TestSelectWithOffsetCommand

Function TestSelectWithOffsetCommand

parser/parser_test.go:393–424  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

391}
392
393func TestSelectWithOffsetCommand(t *testing.T) {
394 input := "SELECT * FROM tableName OFFSET 5;"
395 expectedOffsetCommand := ast.OffsetCommand{
396 Token: token.Token{Type: token.OFFSET, Literal: "OFFSET"},
397 Count: 5,
398 }
399
400 expectedTableName := "tableName"
401 expectedSpaces := []ast.Space{{ColumnName: token.Token{Type: token.ASTERISK, Literal: "*"}}}
402
403 lexer := lexer.RunLexer(input)
404 parserInstance := New(lexer)
405 sequences, err := parserInstance.ParseSequence()
406 if err != nil {
407 t.Fatalf("Got error from parser: %s", err)
408 }
409
410 if len(sequences.Commands) != 1 {
411 t.Fatalf("sequences does not contain 1 statements. got=%d", len(sequences.Commands))
412 }
413
414 selectCommand := sequences.Commands[0].(*ast.SelectCommand)
415
416 if !testSelectStatement(t, selectCommand, expectedTableName, expectedSpaces, false) {
417 return
418 }
419
420 if !selectCommand.HasOffsetCommand() {
421 t.Fatalf("select command should have offset command")
422 }
423 testOffsetCommands(t, expectedOffsetCommand, selectCommand.OffsetCommand)
424}
425
426func TestSelectWithLimitAndOffsetCommand(t *testing.T) {
427 input := "SELECT * FROM tableName ORDER BY colName1 DESC LIMIT 2 OFFSET 13;"

Callers

nothing calls this directly

Calls 6

RunLexerFunction · 0.92
testSelectStatementFunction · 0.85
testOffsetCommandsFunction · 0.85
ParseSequenceMethod · 0.80
HasOffsetCommandMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected