Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct { // Name is the name of the column. Name string // DbType is the database system name of the column type, e.g. VARCHAR, INT, etc. DbType string // ScanType returns a Go type suitable for scanning into using Rows.Scan. ScanType string // Nullable specify whether a column can be null or not. Nullable bool }
Column is data of database column.
type DdlQueryData ¶
type DdlQueryData struct { // Name is the name of query. Name string // TableName is the name of table that created using this DDL. TableName string // Columns is list of columns inside the created table. Columns []Column // SQL is the raw SQL query. SQL string }
DdlQueryData is data for query that used to create tables.
type ExecQueryData ¶
type ExecQueryData struct { // Name is the name of query. Name string // Params is list of parameters used to modify data. Params []Parameter // SQL is the raw SQL query. SQL string }
ExecQueryData is data for executable query that used to modify data.
type Generator ¶
type Generator struct { // DstDir is destination directory to store the generated code. DstDir string // PackageName is the name of package for the generated code. PackageName string // DdlQueries is data of DDL queries that will be generated. DdlQueries []DdlQueryData // SelectQueries is data of SELECT and GET queries that will be generated. SelectQueries []SelectQueryData // ExecQueries is data of EXEC queries that will be generated. ExecQueries []ExecQueryData // ColumnTypeConverter is map of function to convert column's database type // into a suitable Go type. ColumnTypeConverter func(column Column) string // AdditionalImports is list of additional packages that should be imported // in the generated code, for example because of the additional types that // specified in ColumnTypeConverter. AdditionalImports []string // contains filtered or unexported fields }
Generator is object to generate the code for database storage.
type Parameter ¶
type Parameter struct { // Name is the name of the parameter. Name string // Required specify whether this parameter is required or not. Required bool }
Parameter is data for query parameter.
type RawQueryData ¶
type RawQueryData struct { // Type is the type of query. Type QueryType // Name is the name of query. Name string // Props is list of property that defined for this query. Props map[string]string // SQL is the raw SQL query. SQL string // SourceFile is the file where this query declared. SourceFile string // SourceLine is the line number where this query declared. SourceLine int }
RawQueryData is the basic data which parsed from SQL file.
type SelectQueryData ¶
type SelectQueryData struct { // Name is the name of query. Name string // Columns is list of columns in fetched data. Columns []Column // Params is list of parameters used to fetch data. Params []Parameter // ResultEntity is the name of entity that will be used to store result of this query. ResultEntity string // InputEntity is the name of entity that will be used to store parameter for this query. InputEntity string // SQL is the raw SQL query. SQL string // SingleResult specify if this query return single row or multi rows. SingleResult bool }
SelectQueryData is data for query that used to fetch data from database.
type SqlParser ¶
type SqlParser struct { // TmpDB is temporary database that used to test queries. // WARNING: make sure it's not pointed to production database. TmpDB *sqlx.DB // SrcDir is source directory that contains SQL files. SrcDir string // contains filtered or unexported fields }
SqlParser is the object that used to parse SQL files.
func (*SqlParser) Parse ¶
func (p *SqlParser) Parse() (ddlQueries []DdlQueryData, selectQueries []SelectQueryData, execQueries []ExecQueryData, err error)
type SqlVariable ¶
type SqlVariable struct { // Name is the name of variable. Name string // SQL is the raw SQL query. SQL string // SourceFile is the file where this variable declared. SourceFile string // SourceLine is the line number where this variable declared. SourceLine int }
SqlVariable is the data of variable which parsed from SQL file.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.