Tagging column names are not uppercase with oci8 #2176

Open
opened 2022-09-06 03:52:41 +00:00 by monogemes · 0 comments

version : v1.3.2
database : oracle 11g
driver : oci8

problem:

engin, err = xorm.NewEngine("oci8", dataSource)
engine.Where("id = ?", 1).Get(&whiteList)

SQL LOG

[SQL] SELECT "id", "client_id", "ip" FROM (SELECT "id", "client_id", "ip",ROWNUM RN FROM (SELECT "id", "client_id", "ip" FROM "MYDB"."T_WHITELIST" WHERE (id = :1)) at WHERE ROWNUM <= 1) aat WHERE RN > 0 [1]

which throws

errr:ORA-00904: "ip": invalid identifier

cause column name with "" in oracle is case sensitive.

Struct

type WhiteList struct {
	Id       string `xorm: "pk 'ID'"`
	ClientId string `xorm:'CLIENT_ID'`
	Ip       string `xorm:'IP'`
}

func (t *WhiteList) TableName() string {
	return "MYDB.T_WHITELIST"
}

Table

create table MYDB.T_WHITELIST
(
    ID        NUMBER not null
        constraint T_IP_WHITELIST_PK
            primary key,
    CLIENT_ID VARCHAR2(50),
    IP        VARCHAR2(255)
)

Function

	var whiteList models.WhiteList
	var errr error
	_, errr = engine.Where("id = ?", 1).Get(&whiteList)
	if errr != nil {
		fmt.Printf("errr:%s", errr)
	}
	fmt.Printf("clientId:%s", whiteList.ClientId)

version : v1.3.2 database : oracle 11g driver : oci8 ### problem: ``` engin, err = xorm.NewEngine("oci8", dataSource) engine.Where("id = ?", 1).Get(&whiteList) ``` > SQL LOG ` [SQL] SELECT "id", "client_id", "ip" FROM (SELECT "id", "client_id", "ip",ROWNUM RN FROM (SELECT "id", "client_id", "ip" FROM "MYDB"."T_WHITELIST" WHERE (id = :1)) at WHERE ROWNUM <= 1) aat WHERE RN > 0 [1]` which throws ``` errr:ORA-00904: "ip": invalid identifier ``` cause column name with "" in oracle is case sensitive. Struct ``` type WhiteList struct { Id string `xorm: "pk 'ID'"` ClientId string `xorm:'CLIENT_ID'` Ip string `xorm:'IP'` } func (t *WhiteList) TableName() string { return "MYDB.T_WHITELIST" } ``` Table ``` create table MYDB.T_WHITELIST ( ID NUMBER not null constraint T_IP_WHITELIST_PK primary key, CLIENT_ID VARCHAR2(50), IP VARCHAR2(255) ) ``` Function ``` var whiteList models.WhiteList var errr error _, errr = engine.Where("id = ?", 1).Get(&whiteList) if errr != nil { fmt.Printf("errr:%s", errr) } fmt.Printf("clientId:%s", whiteList.ClientId) ```
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#2176
No description provided.