Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( MockExecuteStatement = "UPDATE users SET name = $1 age = $2 WHERE id = $3" MockExecuteParameters = []any{"John", 30, 1} MockQueryStatement = "SELECT * FROM users WHERE age >= $1 and age < $2 and active = $3" MockQueryParameters = []any{18, 21, true} MockQueryScalarStatement = "SELECT COUNT(*) FROM users WHERE age >= $1 and age < $2 and active = $3" MockQueryScalarParameters = []any{0, 18, false} )
var DatabaseQueryCallStack = testutils.NewCallStack()
Functions ¶
This section is empty.
Types ¶
type HostQueryResponse ¶
type Location ¶ added in v0.17.0
type Location struct {
// The Longitude coordinate of the location.
Longitude float64 `json:"longitude"`
// The Latitude coordinate of the location.
Latitude float64 `json:"latitude"`
}
Represents a location on Earth, having longitude and latitude coordinates. Correctly serializes to and from a SQL point type, in (longitude, latitude) order.
Note that this struct is identical to the Point struct, but uses different field names.
func NewLocation ¶ added in v0.17.0
Creates a new Location with the specified longitude and latitude coordinates.
func ParseLocation ¶ added in v0.17.0
Parses a location from a string in the format "(Longitude,Latitude)" or "POINT (Longitude Latitude)".
func (*Location) MarshalJSON ¶ added in v0.17.0
func (*Location) UnmarshalJSON ¶ added in v0.17.0
type Point ¶ added in v0.17.0
type Point struct {
// The X coordinate of the point.
X float64 `json:"x"`
// The Y coordinate of the point.
Y float64 `json:"y"`
}
Represents a point in 2D space, having X and Y coordinates. Correctly serializes to and from a SQL point type, in (X, Y) order.
Note that this struct is identical to the Location struct, but uses different field names.
func ParsePoint ¶ added in v0.17.0
Parses a Point from a string in the format "(X,Y)", or "POINT (X Y)".
func (*Point) MarshalJSON ¶ added in v0.17.0
func (*Point) UnmarshalJSON ¶ added in v0.17.0
type QueryResponse ¶ added in v0.17.0
type QueryResponse[T any] struct { // The number of rows affected by the query, which typically corresponds to the number of rows returned. RowsAffected uint32 // The ID of the last row inserted by the query, if applicable. // Note that not all databases support this feature. LastInsertId uint64 // The rows returned by the query. Rows []T }
Represents the result of a database query that returns rows.
type Response ¶ added in v0.17.0
type Response struct {
// The number of rows affected by the query.
RowsAffected uint32
// The ID of the last row inserted by the query, if applicable.
// Note that not all databases support this feature.
LastInsertId uint64
}
Represents the result of a database query that does not return data.
type ScalarResponse ¶ added in v0.17.0
type ScalarResponse[T any] struct { // The number of rows affected by the query, which is typically 1 unless the query failed, // or had side effects that modified more than one row. RowsAffected uint32 // The ID of the last row inserted by the query, if applicable. // Note that not all databases support this feature. LastInsertId uint64 // The scalar value returned by the query. Value T }
Represents the result of a database query that returns a single scalar value.
func QueryScalar ¶
func QueryScalar[T any](connection, dbType, statement string, params ...any) (*ScalarResponse[T], error)
Executes a database query that returns a single scalar value. The type parameter determines the type of the scalar value.