commands

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2025 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	CheckMinLen(expected int) error
	CheckExactLen(expected int) error
	SelectCommand(k int) string
	SelectNormalizedCommand(k int) (string, bool)
	ReplaceCommand(original, new string) Command
	NormalizeName(string) string
	RemoveAfter(k int) Command
	Normalized() string
	Raw() string
	String() string
}

type CommandString

type CommandString struct {
	// contains filtered or unexported fields
}
var EmptyCommandString *CommandString = CommandFromString("")

EmptyCommandString is an empty CommandString

func CommandFromString

func CommandFromString(command string) *CommandString

CommandFromString creates a CommandString from a string, normalizing it while still allowing access to the raw command

func (*CommandString) CheckExactLen

func (c *CommandString) CheckExactLen(expected int) error

CheckExactLen checks if the command has exactly expected arguments

func (*CommandString) CheckMinLen

func (c *CommandString) CheckMinLen(expected int) error

CheckMinLen checks if the command has at least expected arguments

func (*CommandString) From

func (c *CommandString) From(start int) *SqlCommand

From returns a new SqlCommand with the first n commands removed.

func (*CommandString) NormalizeName

func (c *CommandString) NormalizeName(name string) string

func (*CommandString) Normalized

func (c *CommandString) Normalized() string

func (*CommandString) NormalizedLen

func (c *CommandString) NormalizedLen() int

NormalizedLen returns the number of parts in the normalized command.

func (*CommandString) Raw

func (c *CommandString) Raw() string

func (*CommandString) RemoveAfter

func (c *CommandString) RemoveAfter(k int) Command

RemoveAfter returns a new CommandString with the last k commands removed.

func (*CommandString) ReplaceCommand

func (c *CommandString) ReplaceCommand(original, new string) Command

ReplaceCommand returns the raw command with the first occurrence of the original command replaced by the new command.

func (*CommandString) SelectCommand

func (c *CommandString) SelectCommand(k int) string

SelectCommand returns the kth command from the raw command.

func (*CommandString) SelectNormalizedCommand

func (c *CommandString) SelectNormalizedCommand(k int) (part string, ok bool)

SelectNormalizedCommand returns the kth command from the normalized command.

func (*CommandString) String

func (c *CommandString) String() string

type SqlCommand

type SqlCommand struct {
	CommandString
}

func (*SqlCommand) IsQueryChangeSchema

func (c *SqlCommand) IsQueryChangeSchema() bool

func (*SqlCommand) IsQueryReadOnly

func (c *SqlCommand) IsQueryReadOnly() bool

IsQueryReadOnly returns whether a query is read-only or not

func (*SqlCommand) NonAllowedQuery

func (c *SqlCommand) NonAllowedQuery() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL