Documentation ¶
Overview ¶
Package option contains the generated go code for protoql options.
Index ¶
- Variables
- type Query
- func (*Query) Descriptor() ([]byte, []int)deprecated
- func (x *Query) GetName() string
- func (x *Query) GetQuery() string
- func (x *Query) GetRead() *Read
- func (x *Query) GetReadOne() *ReadOne
- func (m *Query) GetTyp() isQuery_Typ
- func (x *Query) GetWrite() *Write
- func (*Query) ProtoMessage()
- func (x *Query) ProtoReflect() protoreflect.Message
- func (x *Query) Reset()
- func (x *Query) String() string
- type Query_Read
- type Query_ReadOne
- type Query_Write
- type Read
- type ReadOne
- type Relation
- type ScanType
- type Variable
- type Write
Constants ¶
This section is empty.
Variables ¶
var ( ScanType_name = map[int32]string{ 0: "DIRECT", 1: "COMPOSITE", 2: "JSON", } ScanType_value = map[string]int32{ "DIRECT": 0, "COMPOSITE": 1, "JSON": 2, } )
Enum value maps for ScanType.
var ( // primary_key tells protoc-gen-go-queries that the field is a primary key and // may be used to identify rows. If multiple fields are marked as a primary // key, they will be treated as a multi-column primary key. // // optional bool primary_key = 3000; E_PrimaryKey = &file_protoql_options_proto_extTypes[0] // skip allows you to skip individual fields. Setting this to true will skip a // field. // // optional bool skip = 3001; E_Skip = &file_protoql_options_proto_extTypes[1] // flatten tells protoql to treat sub-fields of this field as if they were // part of the parent message type. // // Example: // // message Account { // string email = 1 [(protoql.primary_key) = 1]; // } // // message AccountPass { // option (protoql.rel) = {namespace="public",name="account"}; // Account account = 1 [(protoql.flatten) = true]; // string passhash = 2; // } // // optional bool flatten = 3002; E_Flatten = &file_protoql_options_proto_extTypes[2] // column may be used to explicitly define the column name rather than relying // on autogenerated column names. // // optional string column = 3003; E_Column = &file_protoql_options_proto_extTypes[3] // generated may be used to tell protoql that the value of this field is // generated in the database and should not be included in query arguments // (e.g. autogenerated `Create` methods or uses of `varFields` in custom // queries). It will still be scanned in result sets. // // optional bool generated = 3004; E_Generated = &file_protoql_options_proto_extTypes[4] )
Extension fields to descriptorpb.FieldOptions.
var ( // gen_crud may be used to tell protoql to auto-generate // create/read/update/delete query methods. If this message type does not // have any primary key(s) defined (see FieldOptions extensions), then only // a create method will be generated, since protoql does not know how to // look up the row related to a message. // // optional bool gen_crud = 3000; E_GenCrud = &file_protoql_options_proto_extTypes[5] // rel may be used to explicitly define a relation that this message is // associated with. Messages that are associated with more than one relation // should be configured either on fields or in a config file. // // Most of the time, this refers to a table. However, for composite types, // this may be used to reference the custom type. // // optional protoql.Relation rel = 3001; E_Rel = &file_protoql_options_proto_extTypes[6] // scan_type tells protoql the type of marshal/unmarshal it should use to // implement driver.Valuer and sql.Scanner types. // // optional protoql.ScanType scan_type = 3002; E_ScanType = &file_protoql_options_proto_extTypes[7] )
Extension fields to descriptorpb.MessageOptions.
var ( // message_gen_crud sets the default gen_crud value on all messages in a file. This // may be overridden on individual message types within the file. // // optional bool message_gen_crud = 3000; E_MessageGenCrud = &file_protoql_options_proto_extTypes[10] // query allows for defining custom queries. Since this is a repeated option, // it may be declared multiple times and will result in multiple custom // queries. // // repeated protoql.Query query = 3001; E_Query = &file_protoql_options_proto_extTypes[11] // message_scan_type sets the default scan_type value on all messages in a // file. This may be overridden on individual message types within the file. // // optional protoql.ScanType message_scan_type = 3002; E_MessageScanType = &file_protoql_options_proto_extTypes[12] )
Extension fields to descriptorpb.FileOptions.
var ( // json tells protoql to also make the enum type implement json.Marshaler and // json.Unmarshaler. The json values will match the value used in the database // (see the sql_value option). // // optional bool json = 3000; E_Json = &file_protoql_options_proto_extTypes[8] )
Extension fields to descriptorpb.EnumOptions.
var ( // sql_value sets the database value of an enum value. This will be used // instead of the default when translating to/from values in the database. // // optional string sql_value = 3000; E_SqlValue = &file_protoql_options_proto_extTypes[9] )
Extension fields to descriptorpb.EnumValueOptions.
var File_protoql_options_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query struct { // name is a unique name to identify this query by. The generated method name // will match the exported camel-case version of this name. // // For example, `name: "FooBar"` and `name: "foo_bar"` will both result in a // method named FooBar. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // query is the SQL that will be run. Parameters and results may be referenced // in this query using golang text/template syntax in order to ensure that // query variables and scan order is what you expect. // // See the `git.sr.ht/~nelsam/protoql/gen/custom` package docs for details // about the template functions and variables that are available. Query string `protobuf:"bytes,2,opt,name=query,proto3" json:"query,omitempty"` // typ is the type of this query and contains param/result types. // // Types that are assignable to Typ: // // *Query_Write // *Query_ReadOne // *Query_Read Typ isQuery_Typ `protobuf_oneof:"typ"` // contains filtered or unexported fields }
Query represents a single custom query that will generate a custom query method on the wrapper struct.
func (*Query) Descriptor
deprecated
func (*Query) GetReadOne ¶
func (*Query) ProtoMessage ¶
func (*Query) ProtoMessage()
func (*Query) ProtoReflect ¶
func (x *Query) ProtoReflect() protoreflect.Message
type Query_Read ¶
type Query_Read struct {
Read *Read `protobuf:"bytes,5,opt,name=read,proto3,oneof"`
}
type Query_ReadOne ¶
type Query_ReadOne struct {
ReadOne *ReadOne `protobuf:"bytes,4,opt,name=read_one,json=readOne,proto3,oneof"`
}
type Query_Write ¶
type Query_Write struct {
Write *Write `protobuf:"bytes,3,opt,name=write,proto3,oneof"`
}
type Read ¶
type Read struct { Params []*Variable `protobuf:"bytes,1,rep,name=params,proto3" json:"params,omitempty"` Results []*Variable `protobuf:"bytes,2,rep,name=results,proto3" json:"results,omitempty"` // contains filtered or unexported fields }
Read represents a query that will read zero or more tuples. The generated code will return an iterator that will scan and return tuples on demand.
func (*Read) Descriptor
deprecated
func (*Read) GetResults ¶
func (*Read) ProtoMessage ¶
func (*Read) ProtoMessage()
func (*Read) ProtoReflect ¶
func (x *Read) ProtoReflect() protoreflect.Message
type ReadOne ¶
type ReadOne struct { Params []*Variable `protobuf:"bytes,1,rep,name=params,proto3" json:"params,omitempty"` Results []*Variable `protobuf:"bytes,2,rep,name=results,proto3" json:"results,omitempty"` // contains filtered or unexported fields }
ReadOne represents a query that will read a single tuple from the database. The generated code will automatically scan the tuple and return it.
func (*ReadOne) Descriptor
deprecated
func (*ReadOne) GetResults ¶
func (*ReadOne) ProtoMessage ¶
func (*ReadOne) ProtoMessage()
func (*ReadOne) ProtoReflect ¶
func (x *ReadOne) ProtoReflect() protoreflect.Message
type Relation ¶
type Relation struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"` // contains filtered or unexported fields }
Relation is an SQL relation - for exaample, a table. For the purposes of protoql, a relation has a namespace (usually a schema) and a name.
func (*Relation) Descriptor
deprecated
func (*Relation) GetNamespace ¶
func (*Relation) ProtoMessage ¶
func (*Relation) ProtoMessage()
func (*Relation) ProtoReflect ¶
func (x *Relation) ProtoReflect() protoreflect.Message
type ScanType ¶
type ScanType int32
ScanType represents the method that should be used to scan a value from the database into a field of this type.
const ( // DIRECT represents normal, direct scanning, for values like strings that can // rely on default behavior. ScanType_DIRECT ScanType = 0 // COMPOSITE represents database-level custom composite types. ScanType_COMPOSITE ScanType = 1 // JSON represents json(b) columns that should implement json // marshal/unmarshal methods in the database. ScanType_JSON ScanType = 2 )
func (ScanType) Descriptor ¶
func (ScanType) Descriptor() protoreflect.EnumDescriptor
func (ScanType) EnumDescriptor
deprecated
func (ScanType) Number ¶
func (x ScanType) Number() protoreflect.EnumNumber
func (ScanType) Type ¶
func (ScanType) Type() protoreflect.EnumType
type Variable ¶
type Variable struct { // name is a unique identifier for the scope of a custom query, used as the // parameter or result name in the generated go code and for referencing // parameters or results in custom query templates. Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // type_name must match either a built-in type or the name of a custom type // (enum, message, etc). If the type is imported and the import specifies a // package namespace, type_name should include the namespace. The file in // question *must* be imported, even if the import is not otherwise used. // // For example, to use an Account message type imported from a // 'user'-namespaced file, type_name should be "user.Account". // // Note: it would be much cleaner to literally reference the imported type, // but we have thus far been unable to do so. We are still capable of erroring // out if the import cannot be found, but since protoc doesn't realize that // the import is being used, we get an ugly warning about unused imports. TypeName string `protobuf:"bytes,2,opt,name=type_name,json=typeName,proto3" json:"type_name,omitempty"` // contains filtered or unexported fields }
Variable represents any variable, parameter, or return value.
func (*Variable) Descriptor
deprecated
func (*Variable) GetTypeName ¶
func (*Variable) ProtoMessage ¶
func (*Variable) ProtoMessage()
func (*Variable) ProtoReflect ¶
func (x *Variable) ProtoReflect() protoreflect.Message
type Write ¶
type Write struct { Params []*Variable `protobuf:"bytes,1,rep,name=params,proto3" json:"params,omitempty"` // contains filtered or unexported fields }
Write represents a write-only query.
func (*Write) Descriptor
deprecated
func (*Write) ProtoMessage ¶
func (*Write) ProtoMessage()
func (*Write) ProtoReflect ¶
func (x *Write) ProtoReflect() protoreflect.Message