teescan

package
v0.33.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PutScanner

func PutScanner(s *Scanner)

func ValueString

func ValueString(value interface{}) (string, error)

ValueString is a type assertion function for a Scanner that receives untyped SQL parameter value and returns string representation of the SQL parameter appropriate for the substitution into the plain SQL query.

Types

type AssertFunc

type AssertFunc func(interface{}) (string, error)

AssertFunc is the signature of the function used to assert type of the parameter value. The argument are an untyped SQL parameter value. The return value are string representation of the SQL parameter appropriate for the substitution into the plain SQL query.

Scanning stops if the function returns an error.

type Scanner

type Scanner struct {
	Values      []driver.Value      // Non named/non ordinal parameters in database/sql/driver representation.
	NamedValues []driver.NamedValue // Named or ordinal parameters in database/sql/driver representation.
	Assert      AssertFunc          // The function to get string representation of the SQL parameter.
	Reverse     bool                // Scans parameters from ending to beginning
	// contains filtered or unexported fields
}

Scanner provides a convenient interface for getting string representation of the SQL parameters by slice of the parameters from database/sql/driver. Successive calls to the Scan method will step through the name and ordinal position of the parameter identifier and parameter value.

The specification of a parameter value is defined by a Assert function of type AssertFunc; the default Assert function provides access to an string representation of the SQL parameter.

Scanning stops unrecoverably at the first error.

func GetScanner

func GetScanner() *Scanner

func (*Scanner) Err

func (s *Scanner) Err() error

Err returns the first error that was encountered by the Scanner.

func (*Scanner) Param

func (s *Scanner) Param() (string, int, string)

Param returns the most recent name and ordinal position of the parameter identifier and string representation of the SQL parameter value generated by a call to Scan.

If the name is not empty it should be used for the parameter identifier and not the ordinal position.

If name of the parameter identifier is empty and ordinal position is equal to zero therefore SQL query contains non named/non ordinal parameter identifiers (for example ? question characters).

func (*Scanner) Scan

func (s *Scanner) Scan() bool

Jump to

Keyboard shortcuts

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