[BUG]新版xorm 在JOIN时不再自动对表名进行 table 处理么? #1074

Closed
opened 2018-08-20 03:39:45 +00:00 by javasgl · 0 comments
javasgl commented 2018-08-20 03:39:45 +00:00 (Migrated from github.com)
session.Join("INNER","order","`t1`.id=`order`.id")
SELECT * FROM `t1` INNER JOIN order ON `t1`.id = `order`.id

生成SQL对 Join的表名没有做处理,导致 order 表 和 SQL 的 order by 关键字冲突,SQL语句报错。
正确的语句应该是

SELECT * FROM `t1` INNER JOIN `order` ON `t1`.id = `order`.id

在低版本中是有的,低版本中处理表名的方法是:

// Quote Use QuoteStr quote the string sql
func (engine *Engine) Quote(sql string) string {
	return engine.quoteTable(sql)
}
``` session.Join("INNER","order","`t1`.id=`order`.id") ``` ``` SELECT * FROM `t1` INNER JOIN order ON `t1`.id = `order`.id ``` 生成SQL对 Join的表名没有做处理,导致 order 表 和 SQL 的 order by 关键字冲突,SQL语句报错。 正确的语句应该是 ``` SELECT * FROM `t1` INNER JOIN `order` ON `t1`.id = `order`.id ``` 在低版本中是有的,低版本中处理表名的方法是: ``` // Quote Use QuoteStr quote the string sql func (engine *Engine) Quote(sql string) string { return engine.quoteTable(sql) } ```
lunny modified the milestone from 0.8 to 0.8.2 2019-10-21 03:48:53 +00:00
lunny modified the milestone from 0.8.2 to 1.1.1 2020-02-21 12:51:52 +00:00
lunny closed this issue 2020-02-25 00:01:40 +00:00
lunny modified the milestone from 1.1.1 to 1.0.0 2020-03-03 13:03:30 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1074
No description provided.