Remove quotestr totally (#1366)

* remove QuoteStr() totally

* update xorm.core -> v0.7.0

* update dialect Quote
This commit is contained in:
BetaCat 2019-07-24 14:38:05 +08:00 committed by Lunny Xiao
parent 4b0ff8ad27
commit b757473de7
6 changed files with 896 additions and 920 deletions

View File

@ -286,10 +286,6 @@ func (db *mssql) Quote(name string) string {
return "\"" + name + "\"" return "\"" + name + "\""
} }
func (db *mssql) QuoteStr() string {
return "\""
}
func (db *mssql) SupportEngine() bool { func (db *mssql) SupportEngine() bool {
return false return false
} }

View File

@ -220,7 +220,7 @@ func (db *mysql) SqlType(c *core.Column) string {
case core.TimeStampz: case core.TimeStampz:
res = core.Char res = core.Char
c.Length = 64 c.Length = 64
case core.Enum: //mysql enum case core.Enum: // mysql enum
res = core.Enum res = core.Enum
res += "(" res += "("
opts := "" opts := ""
@ -229,7 +229,7 @@ func (db *mysql) SqlType(c *core.Column) string {
} }
res += strings.TrimLeft(opts, ",") res += strings.TrimLeft(opts, ",")
res += ")" res += ")"
case core.Set: //mysql set case core.Set: // mysql set
res = core.Set res = core.Set
res += "(" res += "("
opts := "" opts := ""
@ -278,10 +278,6 @@ func (db *mysql) Quote(name string) string {
return "`" + name + "`" return "`" + name + "`"
} }
func (db *mysql) QuoteStr() string {
return "`"
}
func (db *mysql) SupportEngine() bool { func (db *mysql) SupportEngine() bool {
return true return true
} }
@ -360,7 +356,7 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column
var len1, len2 int var len1, len2 int
if len(cts) == 2 { if len(cts) == 2 {
idx := strings.Index(cts[1], ")") idx := strings.Index(cts[1], ")")
if colType == core.Enum && cts[1][0] == '\'' { //enum if colType == core.Enum && cts[1][0] == '\'' { // enum
options := strings.Split(cts[1][0:idx], ",") options := strings.Split(cts[1][0:idx], ",")
col.EnumOptions = make(map[string]int) col.EnumOptions = make(map[string]int)
for k, v := range options { for k, v := range options {
@ -408,7 +404,7 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column
col.IsPrimaryKey = true col.IsPrimaryKey = true
} }
if colKey == "UNI" { if colKey == "UNI" {
//col.is // col.is
} }
if extra == "auto_increment" { if extra == "auto_increment" {
@ -559,8 +555,6 @@ func (db *mysql) CreateTableSql(table *core.Table, tableName, storeEngine, chars
sql += " DEFAULT CHARSET " + charset sql += " DEFAULT CHARSET " + charset
} }
if db.rowFormat != "" { if db.rowFormat != "" {
sql += " ROW_FORMAT=" + db.rowFormat sql += " ROW_FORMAT=" + db.rowFormat
} }
@ -633,7 +627,7 @@ func (p *mysqlDriver) Parse(driverName, dataSourceName string) (*core.Uri, error
`\/(?P<dbname>.*?)` + // /dbname `\/(?P<dbname>.*?)` + // /dbname
`(?:\?(?P<params>[^\?]*))?$`) // [?param1=value1&paramN=valueN] `(?:\?(?P<params>[^\?]*))?$`) // [?param1=value1&paramN=valueN]
matches := dsnPattern.FindStringSubmatch(dataSourceName) matches := dsnPattern.FindStringSubmatch(dataSourceName)
//tlsConfigRegister := make(map[string]*tls.Config) // tlsConfigRegister := make(map[string]*tls.Config)
names := dsnPattern.SubexpNames() names := dsnPattern.SubexpNames()
uri := &core.Uri{DbType: core.MYSQL} uri := &core.Uri{DbType: core.MYSQL}

View File

@ -230,271 +230,271 @@ var (
"LOGGING": true, "LOGGING": true,
"LOGICAL_READS_PER_CALL": true, "LOGICAL_READS_PER_CALL": true,
"LOGICAL_READS_PER_SESSION": true, "LOGICAL_READS_PER_SESSION": true,
"LONG": true, "LONG": true,
"MANAGE": true, "MANAGE": true,
"MASTER": true, "MASTER": true,
"MAX": true, "MAX": true,
"MAXARCHLOGS": true, "MAXARCHLOGS": true,
"MAXDATAFILES": true, "MAXDATAFILES": true,
"MAXEXTENTS": true, "MAXEXTENTS": true,
"MAXINSTANCES": true, "MAXINSTANCES": true,
"MAXLOGFILES": true, "MAXLOGFILES": true,
"MAXLOGHISTORY": true, "MAXLOGHISTORY": true,
"MAXLOGMEMBERS": true, "MAXLOGMEMBERS": true,
"MAXSIZE": true, "MAXSIZE": true,
"MAXTRANS": true, "MAXTRANS": true,
"MAXVALUE": true, "MAXVALUE": true,
"MIN": true, "MIN": true,
"MEMBER": true, "MEMBER": true,
"MINIMUM": true, "MINIMUM": true,
"MINEXTENTS": true, "MINEXTENTS": true,
"MINUS": true, "MINUS": true,
"MINVALUE": true, "MINVALUE": true,
"MLSLABEL": true, "MLSLABEL": true,
"MLS_LABEL_FORMAT": true, "MLS_LABEL_FORMAT": true,
"MODE": true, "MODE": true,
"MODIFY": true, "MODIFY": true,
"MOUNT": true, "MOUNT": true,
"MOVE": true, "MOVE": true,
"MTS_DISPATCHERS": true, "MTS_DISPATCHERS": true,
"MULTISET": true, "MULTISET": true,
"NATIONAL": true, "NATIONAL": true,
"NCHAR": true, "NCHAR": true,
"NCHAR_CS": true, "NCHAR_CS": true,
"NCLOB": true, "NCLOB": true,
"NEEDED": true, "NEEDED": true,
"NESTED": true, "NESTED": true,
"NETWORK": true, "NETWORK": true,
"NEW": true, "NEW": true,
"NEXT": true, "NEXT": true,
"NOARCHIVELOG": true, "NOARCHIVELOG": true,
"NOAUDIT": true, "NOAUDIT": true,
"NOCACHE": true, "NOCACHE": true,
"NOCOMPRESS": true, "NOCOMPRESS": true,
"NOCYCLE": true, "NOCYCLE": true,
"NOFORCE": true, "NOFORCE": true,
"NOLOGGING": true, "NOLOGGING": true,
"NOMAXVALUE": true, "NOMAXVALUE": true,
"NOMINVALUE": true, "NOMINVALUE": true,
"NONE": true, "NONE": true,
"NOORDER": true, "NOORDER": true,
"NOOVERRIDE": true, "NOOVERRIDE": true,
"NOPARALLEL": true, "NOPARALLEL": true,
"NOREVERSE": true, "NOREVERSE": true,
"NORMAL": true, "NORMAL": true,
"NOSORT": true, "NOSORT": true,
"NOT": true, "NOT": true,
"NOTHING": true, "NOTHING": true,
"NOWAIT": true, "NOWAIT": true,
"NULL": true, "NULL": true,
"NUMBER": true, "NUMBER": true,
"NUMERIC": true, "NUMERIC": true,
"NVARCHAR2": true, "NVARCHAR2": true,
"OBJECT": true, "OBJECT": true,
"OBJNO": true, "OBJNO": true,
"OBJNO_REUSE": true, "OBJNO_REUSE": true,
"OF": true, "OF": true,
"OFF": true, "OFF": true,
"OFFLINE": true, "OFFLINE": true,
"OID": true, "OID": true,
"OIDINDEX": true, "OIDINDEX": true,
"OLD": true, "OLD": true,
"ON": true, "ON": true,
"ONLINE": true, "ONLINE": true,
"ONLY": true, "ONLY": true,
"OPCODE": true, "OPCODE": true,
"OPEN": true, "OPEN": true,
"OPTIMAL": true, "OPTIMAL": true,
"OPTIMIZER_GOAL": true, "OPTIMIZER_GOAL": true,
"OPTION": true, "OPTION": true,
"OR": true, "OR": true,
"ORDER": true, "ORDER": true,
"ORGANIZATION": true, "ORGANIZATION": true,
"OSLABEL": true, "OSLABEL": true,
"OVERFLOW": true, "OVERFLOW": true,
"OWN": true, "OWN": true,
"PACKAGE": true, "PACKAGE": true,
"PARALLEL": true, "PARALLEL": true,
"PARTITION": true, "PARTITION": true,
"PASSWORD": true, "PASSWORD": true,
"PASSWORD_GRACE_TIME": true, "PASSWORD_GRACE_TIME": true,
"PASSWORD_LIFE_TIME": true, "PASSWORD_LIFE_TIME": true,
"PASSWORD_LOCK_TIME": true, "PASSWORD_LOCK_TIME": true,
"PASSWORD_REUSE_MAX": true, "PASSWORD_REUSE_MAX": true,
"PASSWORD_REUSE_TIME": true, "PASSWORD_REUSE_TIME": true,
"PASSWORD_VERIFY_FUNCTION": true, "PASSWORD_VERIFY_FUNCTION": true,
"PCTFREE": true, "PCTFREE": true,
"PCTINCREASE": true, "PCTINCREASE": true,
"PCTTHRESHOLD": true, "PCTTHRESHOLD": true,
"PCTUSED": true, "PCTUSED": true,
"PCTVERSION": true, "PCTVERSION": true,
"PERCENT": true, "PERCENT": true,
"PERMANENT": true, "PERMANENT": true,
"PLAN": true, "PLAN": true,
"PLSQL_DEBUG": true, "PLSQL_DEBUG": true,
"POST_TRANSACTION": true, "POST_TRANSACTION": true,
"PRECISION": true, "PRECISION": true,
"PRESERVE": true, "PRESERVE": true,
"PRIMARY": true, "PRIMARY": true,
"PRIOR": true, "PRIOR": true,
"PRIVATE": true, "PRIVATE": true,
"PRIVATE_SGA": true, "PRIVATE_SGA": true,
"PRIVILEGE": true, "PRIVILEGE": true,
"PRIVILEGES": true, "PRIVILEGES": true,
"PROCEDURE": true, "PROCEDURE": true,
"PROFILE": true, "PROFILE": true,
"PUBLIC": true, "PUBLIC": true,
"PURGE": true, "PURGE": true,
"QUEUE": true, "QUEUE": true,
"QUOTA": true, "QUOTA": true,
"RANGE": true, "RANGE": true,
"RAW": true, "RAW": true,
"RBA": true, "RBA": true,
"READ": true, "READ": true,
"READUP": true, "READUP": true,
"REAL": true, "REAL": true,
"REBUILD": true, "REBUILD": true,
"RECOVER": true, "RECOVER": true,
"RECOVERABLE": true, "RECOVERABLE": true,
"RECOVERY": true, "RECOVERY": true,
"REF": true, "REF": true,
"REFERENCES": true, "REFERENCES": true,
"REFERENCING": true, "REFERENCING": true,
"REFRESH": true, "REFRESH": true,
"RENAME": true, "RENAME": true,
"REPLACE": true, "REPLACE": true,
"RESET": true, "RESET": true,
"RESETLOGS": true, "RESETLOGS": true,
"RESIZE": true, "RESIZE": true,
"RESOURCE": true, "RESOURCE": true,
"RESTRICTED": true, "RESTRICTED": true,
"RETURN": true, "RETURN": true,
"RETURNING": true, "RETURNING": true,
"REUSE": true, "REUSE": true,
"REVERSE": true, "REVERSE": true,
"REVOKE": true, "REVOKE": true,
"ROLE": true, "ROLE": true,
"ROLES": true, "ROLES": true,
"ROLLBACK": true, "ROLLBACK": true,
"ROW": true, "ROW": true,
"ROWID": true, "ROWID": true,
"ROWNUM": true, "ROWNUM": true,
"ROWS": true, "ROWS": true,
"RULE": true, "RULE": true,
"SAMPLE": true, "SAMPLE": true,
"SAVEPOINT": true, "SAVEPOINT": true,
"SB4": true, "SB4": true,
"SCAN_INSTANCES": true, "SCAN_INSTANCES": true,
"SCHEMA": true, "SCHEMA": true,
"SCN": true, "SCN": true,
"SCOPE": true, "SCOPE": true,
"SD_ALL": true, "SD_ALL": true,
"SD_INHIBIT": true, "SD_INHIBIT": true,
"SD_SHOW": true, "SD_SHOW": true,
"SEGMENT": true, "SEGMENT": true,
"SEG_BLOCK": true, "SEG_BLOCK": true,
"SEG_FILE": true, "SEG_FILE": true,
"SELECT": true, "SELECT": true,
"SEQUENCE": true, "SEQUENCE": true,
"SERIALIZABLE": true, "SERIALIZABLE": true,
"SESSION": true, "SESSION": true,
"SESSION_CACHED_CURSORS": true, "SESSION_CACHED_CURSORS": true,
"SESSIONS_PER_USER": true, "SESSIONS_PER_USER": true,
"SET": true, "SET": true,
"SHARE": true, "SHARE": true,
"SHARED": true, "SHARED": true,
"SHARED_POOL": true, "SHARED_POOL": true,
"SHRINK": true, "SHRINK": true,
"SIZE": true, "SIZE": true,
"SKIP": true, "SKIP": true,
"SKIP_UNUSABLE_INDEXES": true, "SKIP_UNUSABLE_INDEXES": true,
"SMALLINT": true, "SMALLINT": true,
"SNAPSHOT": true, "SNAPSHOT": true,
"SOME": true, "SOME": true,
"SORT": true, "SORT": true,
"SPECIFICATION": true, "SPECIFICATION": true,
"SPLIT": true, "SPLIT": true,
"SQL_TRACE": true, "SQL_TRACE": true,
"STANDBY": true, "STANDBY": true,
"START": true, "START": true,
"STATEMENT_ID": true, "STATEMENT_ID": true,
"STATISTICS": true, "STATISTICS": true,
"STOP": true, "STOP": true,
"STORAGE": true, "STORAGE": true,
"STORE": true, "STORE": true,
"STRUCTURE": true, "STRUCTURE": true,
"SUCCESSFUL": true, "SUCCESSFUL": true,
"SWITCH": true, "SWITCH": true,
"SYS_OP_ENFORCE_NOT_NULL$": true, "SYS_OP_ENFORCE_NOT_NULL$": true,
"SYS_OP_NTCIMG$": true, "SYS_OP_NTCIMG$": true,
"SYNONYM": true, "SYNONYM": true,
"SYSDATE": true, "SYSDATE": true,
"SYSDBA": true, "SYSDBA": true,
"SYSOPER": true, "SYSOPER": true,
"SYSTEM": true, "SYSTEM": true,
"TABLE": true, "TABLE": true,
"TABLES": true, "TABLES": true,
"TABLESPACE": true, "TABLESPACE": true,
"TABLESPACE_NO": true, "TABLESPACE_NO": true,
"TABNO": true, "TABNO": true,
"TEMPORARY": true, "TEMPORARY": true,
"THAN": true, "THAN": true,
"THE": true, "THE": true,
"THEN": true, "THEN": true,
"THREAD": true, "THREAD": true,
"TIMESTAMP": true, "TIMESTAMP": true,
"TIME": true, "TIME": true,
"TO": true, "TO": true,
"TOPLEVEL": true, "TOPLEVEL": true,
"TRACE": true, "TRACE": true,
"TRACING": true, "TRACING": true,
"TRANSACTION": true, "TRANSACTION": true,
"TRANSITIONAL": true, "TRANSITIONAL": true,
"TRIGGER": true, "TRIGGER": true,
"TRIGGERS": true, "TRIGGERS": true,
"TRUE": true, "TRUE": true,
"TRUNCATE": true, "TRUNCATE": true,
"TX": true, "TX": true,
"TYPE": true, "TYPE": true,
"UB2": true, "UB2": true,
"UBA": true, "UBA": true,
"UID": true, "UID": true,
"UNARCHIVED": true, "UNARCHIVED": true,
"UNDO": true, "UNDO": true,
"UNION": true, "UNION": true,
"UNIQUE": true, "UNIQUE": true,
"UNLIMITED": true, "UNLIMITED": true,
"UNLOCK": true, "UNLOCK": true,
"UNRECOVERABLE": true, "UNRECOVERABLE": true,
"UNTIL": true, "UNTIL": true,
"UNUSABLE": true, "UNUSABLE": true,
"UNUSED": true, "UNUSED": true,
"UPDATABLE": true, "UPDATABLE": true,
"UPDATE": true, "UPDATE": true,
"USAGE": true, "USAGE": true,
"USE": true, "USE": true,
"USER": true, "USER": true,
"USING": true, "USING": true,
"VALIDATE": true, "VALIDATE": true,
"VALIDATION": true, "VALIDATION": true,
"VALUE": true, "VALUE": true,
"VALUES": true, "VALUES": true,
"VARCHAR": true, "VARCHAR": true,
"VARCHAR2": true, "VARCHAR2": true,
"VARYING": true, "VARYING": true,
"VIEW": true, "VIEW": true,
"WHEN": true, "WHEN": true,
"WHENEVER": true, "WHENEVER": true,
"WHERE": true, "WHERE": true,
"WITH": true, "WITH": true,
"WITHOUT": true, "WITHOUT": true,
"WORK": true, "WORK": true,
"WRITE": true, "WRITE": true,
"WRITEDOWN": true, "WRITEDOWN": true,
"WRITEUP": true, "WRITEUP": true,
"XID": true, "XID": true,
"YEAR": true, "YEAR": true,
"ZONE": true, "ZONE": true,
} }
) )
@ -552,11 +552,7 @@ func (db *oracle) IsReserved(name string) bool {
} }
func (db *oracle) Quote(name string) string { func (db *oracle) Quote(name string) string {
return "\"" + name + "\"" return "[" + name + "]"
}
func (db *oracle) QuoteStr() string {
return "\""
} }
func (db *oracle) SupportEngine() bool { func (db *oracle) SupportEngine() bool {
@ -596,7 +592,7 @@ func (db *oracle) CreateTableSql(table *core.Table, tableName, storeEngine, char
sql += col.String(b.dialect) sql += col.String(b.dialect)
} else {*/ } else {*/
sql += col.StringNoPk(db) sql += col.StringNoPk(db)
//} // }
sql = strings.TrimSpace(sql) sql = strings.TrimSpace(sql)
sql += ", " sql += ", "
} }
@ -865,7 +861,7 @@ func (cfg *goracleDriver) Parse(driverName, dataSourceName string) (*core.Uri, e
`\/(?P<dbname>.*?)` + // /dbname `\/(?P<dbname>.*?)` + // /dbname
`(?:\?(?P<params>[^\?]*))?$`) // [?param1=value1&paramN=valueN] `(?:\?(?P<params>[^\?]*))?$`) // [?param1=value1&paramN=valueN]
matches := dsnPattern.FindStringSubmatch(dataSourceName) matches := dsnPattern.FindStringSubmatch(dataSourceName)
//tlsConfigRegister := make(map[string]*tls.Config) // tlsConfigRegister := make(map[string]*tls.Config)
names := dsnPattern.SubexpNames() names := dsnPattern.SubexpNames()
for i, match := range matches { for i, match := range matches {
@ -883,8 +879,8 @@ func (cfg *goracleDriver) Parse(driverName, dataSourceName string) (*core.Uri, e
type oci8Driver struct { type oci8Driver struct {
} }
//dataSourceName=user/password@ipv4:port/dbname // dataSourceName=user/password@ipv4:port/dbname
//dataSourceName=user/password@[ipv6]:port/dbname // dataSourceName=user/password@[ipv6]:port/dbname
func (p *oci8Driver) Parse(driverName, dataSourceName string) (*core.Uri, error) { func (p *oci8Driver) Parse(driverName, dataSourceName string) (*core.Uri, error) {
db := &core.Uri{DbType: core.ORACLE} db := &core.Uri{DbType: core.ORACLE}
dsnPattern := regexp.MustCompile( dsnPattern := regexp.MustCompile(

File diff suppressed because it is too large Load Diff

View File

@ -202,10 +202,6 @@ func (db *sqlite3) Quote(name string) string {
return "`" + name + "`" return "`" + name + "`"
} }
func (db *sqlite3) QuoteStr() string {
return "`"
}
func (db *sqlite3) AutoIncrStr() string { func (db *sqlite3) AutoIncrStr() string {
return "AUTOINCREMENT" return "AUTOINCREMENT"
} }

2
go.mod
View File

@ -15,5 +15,5 @@ require (
github.com/stretchr/testify v1.3.0 github.com/stretchr/testify v1.3.0
github.com/ziutek/mymysql v1.5.4 github.com/ziutek/mymysql v1.5.4
xorm.io/builder v0.3.5 xorm.io/builder v0.3.5
xorm.io/core v0.6.3 xorm.io/core v0.7.0
) )