2017-08-06 15:22:18 +00:00
|
|
|
/* WIP Under Really Heavy Construction */
|
2017-07-12 11:05:18 +00:00
|
|
|
package qgen
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
import "strconv"
|
|
|
|
import "errors"
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
DB_Registry = append(DB_Registry,
|
2017-09-03 04:50:31 +00:00
|
|
|
&Pgsql_Adapter{Name: "pgsql", Buffer: make(map[string]DB_Stmt)},
|
2017-07-12 11:05:18 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
type Pgsql_Adapter struct {
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
Name string // ? - Do we really need this? Can't we hard-code this?
|
2017-09-03 04:50:31 +00:00
|
|
|
Buffer map[string]DB_Stmt
|
2017-07-12 11:05:18 +00:00
|
|
|
BufferOrder []string // Map iteration order is random, so we need this to track the order, so we don't get huge diffs every commit
|
|
|
|
}
|
|
|
|
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
// GetName gives you the name of the database adapter. In this case, it's pgsql
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) GetName() string {
|
|
|
|
return adapter.Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func (adapter *Pgsql_Adapter) GetStmt(name string) DB_Stmt {
|
|
|
|
return adapter.Buffer[name]
|
|
|
|
}
|
|
|
|
|
|
|
|
func (adapter *Pgsql_Adapter) GetStmts() map[string]DB_Stmt {
|
|
|
|
return adapter.Buffer
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
// We may need to change the CreateTable API to better suit PGSQL and the other database drivers which are coming up
|
|
|
|
func (adapter *Pgsql_Adapter) CreateTable(name string, table string, charset string, collation string, columns []DB_Table_Column, keys []DB_Table_Key) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
|
|
|
return "", errors.New("You can't have a table with no columns")
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
|
|
|
var querystr = "CREATE TABLE `" + table + "` ("
|
2017-07-12 11:05:18 +00:00
|
|
|
for _, column := range columns {
|
|
|
|
if column.Auto_Increment {
|
|
|
|
column.Type = "serial"
|
|
|
|
} else if column.Type == "createdAt" {
|
|
|
|
column.Type = "timestamp"
|
|
|
|
} else if column.Type == "datetime" {
|
|
|
|
column.Type = "timestamp"
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
var size string
|
|
|
|
if column.Size > 0 {
|
|
|
|
size = " (" + strconv.Itoa(column.Size) + ")"
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
var end string
|
|
|
|
if column.Default != "" {
|
|
|
|
end = " DEFAULT "
|
2017-09-03 04:50:31 +00:00
|
|
|
if adapter.stringyType(column.Type) && column.Default != "''" {
|
2017-07-12 11:05:18 +00:00
|
|
|
end += "'" + column.Default + "'"
|
|
|
|
} else {
|
|
|
|
end += column.Default
|
|
|
|
}
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
if !column.Null {
|
|
|
|
end += " not null"
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
|
|
|
querystr += "\n\t`" + column.Name + "` " + column.Type + size + end + ","
|
2017-07-12 11:05:18 +00:00
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
if len(keys) > 0 {
|
|
|
|
for _, key := range keys {
|
|
|
|
querystr += "\n\t" + key.Type
|
|
|
|
if key.Type != "unique" {
|
|
|
|
querystr += " key"
|
|
|
|
}
|
|
|
|
querystr += "("
|
2017-09-03 04:50:31 +00:00
|
|
|
for _, column := range strings.Split(key.Columns, ",") {
|
2017-07-12 11:05:18 +00:00
|
|
|
querystr += "`" + column + "`,"
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
querystr = querystr[0:len(querystr)-1] + "),"
|
2017-07-12 11:05:18 +00:00
|
|
|
}
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
|
|
|
querystr = querystr[0:len(querystr)-1] + "\n);"
|
|
|
|
adapter.pushStatement(name, "create-table", querystr)
|
2017-07-12 11:05:18 +00:00
|
|
|
return querystr, nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleInsert(name string, table string, columns string, fields string) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
|
|
|
return "", errors.New("No columns found for SimpleInsert")
|
|
|
|
}
|
|
|
|
if len(fields) == 0 {
|
|
|
|
return "", errors.New("No input data found for SimpleInsert")
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleReplace(name string, table string, columns string, fields string) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
|
|
|
return "", errors.New("No columns found for SimpleInsert")
|
|
|
|
}
|
|
|
|
if len(fields) == 0 {
|
|
|
|
return "", errors.New("No input data found for SimpleInsert")
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implemented, but we need CreateTable and a better installer to *test* it
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleUpdate(name string, table string, set string, where string) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
if set == "" {
|
|
|
|
return "", errors.New("You need to set data in this update statement")
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
var querystr = "UPDATE `" + table + "` SET "
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
for _, item := range processSet(set) {
|
2017-07-12 11:05:18 +00:00
|
|
|
querystr += "`" + item.Column + "` ="
|
|
|
|
for _, token := range item.Expr {
|
2017-09-03 04:50:31 +00:00
|
|
|
switch token.Type {
|
|
|
|
case "function":
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Write a more sophisticated function parser on the utils side.
|
2017-09-03 04:50:31 +00:00
|
|
|
if strings.ToUpper(token.Contents) == "UTC_TIMESTAMP()" {
|
|
|
|
token.Contents = "LOCALTIMESTAMP()"
|
|
|
|
}
|
|
|
|
querystr += " " + token.Contents
|
|
|
|
case "operator", "number", "substitute":
|
|
|
|
querystr += " " + token.Contents
|
|
|
|
case "column":
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
2017-07-12 11:05:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
querystr += ","
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
// Remove the trailing comma
|
2017-09-03 04:50:31 +00:00
|
|
|
querystr = querystr[0 : len(querystr)-1]
|
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
// Add support for BETWEEN x.x
|
|
|
|
if len(where) != 0 {
|
|
|
|
querystr += " WHERE"
|
Added Quick Topic.
Added Attachments.
Added Attachment Media Embeds.
Renamed a load of *Store and *Cache methods to reduce the amount of unneccesary typing.
Added petabytes as a unit and cleaned up a few of the friendly units.
Refactored the username change logic to make it easier to maintain.
Refactored the avatar change logic to make it easier to maintain.
Shadow now uses CSS Variables for most of it's colours. We have plans to transpile this to support older browsers later on!
Snuck some CSS Variables into Tempra Conflux.
Added the GroupCache interface to MemoryGroupStore.
Added the Length method to MemoryGroupStore.
Added support for a site short name.
Added the UploadFiles permission.
Renamed more functions.
Fixed the background for the left gutter on the postbit for Tempra Simple and Shadow.
Added support for if statements operating on int8, int16, int32, int32, int64, uint, uint8, uint16, uint32, uint64, float32, and float64 for the template compiler.
Added support for if statements operating on slices and maps for the template compiler.
Fixed a security exploit in reply editing.
Fixed a bug in the URL detector in the parser where it couldn't find URLs with non-standard ports.
Fixed buttons having blue outlines on focus on Shadow.
Refactored the topic creation logic to make it easier to maintain.
Made a few responsive fixes, but there's still more to do in the following commits!
2017-10-05 10:20:28 +00:00
|
|
|
for _, loc := range processWhere(where) {
|
2017-07-12 11:05:18 +00:00
|
|
|
for _, token := range loc.Expr {
|
2017-09-03 04:50:31 +00:00
|
|
|
switch token.Type {
|
|
|
|
case "function":
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Write a more sophisticated function parser on the utils side. What's the situation in regards to case sensitivity?
|
2017-09-03 04:50:31 +00:00
|
|
|
if strings.ToUpper(token.Contents) == "UTC_TIMESTAMP()" {
|
|
|
|
token.Contents = "LOCALTIMESTAMP()"
|
|
|
|
}
|
|
|
|
querystr += " " + token.Contents
|
|
|
|
case "operator", "number", "substitute":
|
|
|
|
querystr += " " + token.Contents
|
|
|
|
case "column":
|
|
|
|
querystr += " `" + token.Contents + "`"
|
|
|
|
case "string":
|
|
|
|
querystr += " '" + token.Contents + "'"
|
|
|
|
default:
|
|
|
|
panic("This token doesn't exist o_o")
|
2017-07-12 11:05:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
querystr += " AND"
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
querystr = querystr[0 : len(querystr)-4]
|
2017-07-12 11:05:18 +00:00
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
|
|
|
adapter.pushStatement(name, "update", querystr)
|
2017-07-12 11:05:18 +00:00
|
|
|
return querystr, nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleDelete(name string, table string, where string) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
if where == "" {
|
|
|
|
return "", errors.New("You need to specify what data you want to delete")
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
// We don't want to accidentally wipe tables, so we'll have a seperate method for purging tables instead
|
|
|
|
func (adapter *Pgsql_Adapter) Purge(name string, table string) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleSelect(name string, table string, columns string, where string, orderby string, limit string) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
|
|
|
return "", errors.New("No columns found for SimpleSelect")
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleLeftJoin(name string, table1 string, table2 string, columns string, joiners string, where string, orderby string, limit string) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table1 == "" {
|
|
|
|
return "", errors.New("You need a name for the left table")
|
|
|
|
}
|
|
|
|
if table2 == "" {
|
|
|
|
return "", errors.New("You need a name for the right table")
|
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
|
|
|
return "", errors.New("No columns found for SimpleLeftJoin")
|
|
|
|
}
|
|
|
|
if len(joiners) == 0 {
|
|
|
|
return "", errors.New("No joiners found for SimpleLeftJoin")
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleInnerJoin(name string, table1 string, table2 string, columns string, joiners string, where string, orderby string, limit string) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table1 == "" {
|
|
|
|
return "", errors.New("You need a name for the left table")
|
|
|
|
}
|
|
|
|
if table2 == "" {
|
|
|
|
return "", errors.New("You need a name for the right table")
|
|
|
|
}
|
|
|
|
if len(columns) == 0 {
|
|
|
|
return "", errors.New("No columns found for SimpleInnerJoin")
|
|
|
|
}
|
|
|
|
if len(joiners) == 0 {
|
|
|
|
return "", errors.New("No joiners found for SimpleInnerJoin")
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleInsertSelect(name string, ins DB_Insert, sel DB_Select) (string, error) {
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleInsertLeftJoin(name string, ins DB_Insert, sel DB_Join) (string, error) {
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleInsertInnerJoin(name string, ins DB_Insert, sel DB_Join) (string, error) {
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Implement this
|
2017-07-12 11:05:18 +00:00
|
|
|
func (adapter *Pgsql_Adapter) SimpleCount(name string, table string, where string, limit string) (string, error) {
|
|
|
|
if name == "" {
|
|
|
|
return "", errors.New("You need a name for this statement")
|
|
|
|
}
|
|
|
|
if table == "" {
|
|
|
|
return "", errors.New("You need a name for this table")
|
|
|
|
}
|
|
|
|
return "", nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (adapter *Pgsql_Adapter) Write() error {
|
|
|
|
var stmts, body string
|
|
|
|
for _, name := range adapter.BufferOrder {
|
2017-10-14 07:39:22 +00:00
|
|
|
if name[0] == '_' {
|
|
|
|
continue
|
|
|
|
}
|
2017-07-12 11:05:18 +00:00
|
|
|
stmt := adapter.Buffer[name]
|
2017-09-10 16:57:22 +00:00
|
|
|
// TODO: Add support for create-table? Table creation might be a little complex for Go to do outside a SQL file :(
|
2017-07-12 11:05:18 +00:00
|
|
|
if stmt.Type != "create-table" {
|
2017-09-18 17:03:52 +00:00
|
|
|
stmts += "var " + name + "Stmt *sql.Stmt\n"
|
2017-07-12 11:05:18 +00:00
|
|
|
body += `
|
|
|
|
log.Print("Preparing ` + name + ` statement.")
|
2017-09-18 17:03:52 +00:00
|
|
|
` + name + `Stmt, err = db.Prepare("` + stmt.Contents + `")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
`
|
|
|
|
}
|
|
|
|
}
|
2017-09-03 04:50:31 +00:00
|
|
|
|
2017-07-12 11:05:18 +00:00
|
|
|
out := `// +build pgsql
|
|
|
|
|
|
|
|
// This file was generated by Gosora's Query Generator. Please try to avoid modifying this file, as it might change at any time.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
import "database/sql"
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
// nolint
|
2017-07-12 11:05:18 +00:00
|
|
|
` + stmts + `
|
2017-09-03 04:50:31 +00:00
|
|
|
// nolint
|
2017-07-12 11:05:18 +00:00
|
|
|
func _gen_pgsql() (err error) {
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.DebugMode {
|
2017-07-12 11:05:18 +00:00
|
|
|
log.Print("Building the generated statements")
|
|
|
|
}
|
|
|
|
` + body + `
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
`
|
2017-09-03 04:50:31 +00:00
|
|
|
return writeFile("./gen_pgsql.go", out)
|
2017-07-12 11:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Internal methods, not exposed in the interface
|
2017-09-03 04:50:31 +00:00
|
|
|
func (adapter *Pgsql_Adapter) pushStatement(name string, stype string, querystr string) {
|
|
|
|
adapter.Buffer[name] = DB_Stmt{querystr, stype}
|
|
|
|
adapter.BufferOrder = append(adapter.BufferOrder, name)
|
2017-07-12 11:05:18 +00:00
|
|
|
}
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
func (adapter *Pgsql_Adapter) stringyType(ctype string) bool {
|
2017-07-12 11:05:18 +00:00
|
|
|
ctype = strings.ToLower(ctype)
|
|
|
|
return ctype == "char" || ctype == "varchar" || ctype == "timestamp" || ctype == "text"
|
|
|
|
}
|