gosora/query_gen/lib/querygen.go
Azareal e30707bc17 Refactored the installer's code. We're moving towards supporting multiple database engines.
More progress has been made with PostgreSQL, but it's still incomplete and experimental.
The items on the Social Group menu bar are no longer decorative and now let you jump from page to page.
Social Group permissions are now fully functional. More features to come like privacy levels, secondary board permissions, etc. for Social Groups.

One of our dependencies added a dependecy, so we've added that dependency as a dependency.
Tweaked the ForumStore to better conform to the tests.
Fixed an issue with the generated file comment stopping the build tags from being read by the compiler for a few files.
Fixed the test system.
Renamed the route_create_topic handler to route_topic_create_submit
Moved the user table into the query generator.
Fixed a bug in MySQL where it doesn't allow unique keys longer than 180 characters.
Fixed a race condition in the forum deletion handler.
Fixed a crash bug where Gosora crashes when [rand]0[/rand] is passed to the BBCode parser.
Fixed a bug with superadmins not being able to see all the forums they should be able to.
Fixed a bug in simple_forum_session_check where it assumes every request has an error.

Tests:
Added 8 ForumStore tests.
Added 4 Auth tests.
Added 14 bbcode_full_parse tests.
Added 4 bbcode_regex_parse tests.
Fixed a bug in one of the bbcode_full_parse tests.

Apparently, routes.go wasn't commited in the previous commit o_o
2017-07-12 12:05:18 +01:00

135 lines
2.7 KiB
Go

/* WIP Under Construction */
package qgen
import "errors"
var DB_Registry []DB_Adapter
var No_Adapter = errors.New("This adapter doesn't exist")
type DB_Table_Column struct
{
Name string
Type string
Size int
Null bool
Auto_Increment bool
Default string
}
type DB_Table_Key struct
{
Columns string
Type string
}
type DB_Select struct
{
Table string
Columns string
Where string
Orderby string
Limit string
}
type DB_Join struct
{
Table1 string
Table2 string
Columns string
Joiners string
Where string
Orderby string
Limit string
}
type DB_Insert struct
{
Table string
Columns string
Fields string
}
type DB_Column struct
{
Table string
Left string // Could be a function or a column, so I'm naming this Left
Alias string // aka AS Blah, if it's present
Type string // function or column
}
type DB_Field struct
{
Name string
Type string
}
type DB_Where struct
{
Expr []DB_Token // Simple expressions, the innards of functions are opaque for now.
}
type DB_Joiner struct
{
LeftTable string
LeftColumn string
RightTable string
RightColumn string
Operator string
}
type DB_Order struct
{
Column string
Order string
}
type DB_Token struct {
Contents string
Type string // function, operator, column, number, string, substitute
}
type DB_Setter struct {
Column string
Expr []DB_Token // Simple expressions, the innards of functions are opaque for now.
}
type DB_Limit struct {
Offset string // ? or int
MaxCount string // ? or int
}
type DB_Stmt struct
{
Contents string
Type string // create-table, insert, update, delete
}
type DB_Adapter interface {
GetName() string
CreateTable(name string, table string, charset string, collation string, columns []DB_Table_Column, keys []DB_Table_Key) (string, error)
SimpleInsert(name string, table string, columns string, fields string) (string, error)
SimpleReplace(string,string,string,string) (string, error)
SimpleUpdate(string,string,string,string) (string, error)
SimpleDelete(string,string,string) (string, error)
Purge(string,string) (string, error)
SimpleSelect(string,string,string,string,string,string) (string, error)
SimpleLeftJoin(string,string,string,string,string,string,string,string) (string, error)
SimpleInnerJoin(string,string,string,string,string,string,string,string) (string, error)
SimpleInsertSelect(string,DB_Insert,DB_Select) (string,error)
SimpleInsertLeftJoin(string,DB_Insert,DB_Join) (string,error)
SimpleInsertInnerJoin(string,DB_Insert,DB_Join) (string,error)
SimpleCount(string,string,string,string) (string, error)
Write() error
// TO-DO: Add a simple query builder
}
func GetAdapter(name string) (adap DB_Adapter, err error) {
for _, adapter := range DB_Registry {
if adapter.GetName() == name {
return adapter, nil
}
}
return adap, No_Adapter
}