Join is broken since 1.2.0 #2148

Open
opened 2022-05-28 04:33:30 +00:00 by davies · 3 comments

The following code is working with 1.0 and 1.1, but broken with 1.2+

type node struct {
	Inode  Ino    `xorm:"pk"`
	Type   uint8  `xorm:"notnull"`
	Flags  uint8  `xorm:"notnull"`
	Mode   uint16 `xorm:"notnull"`
	Uid    uint32 `xorm:"notnull"`
	Gid    uint32 `xorm:"notnull"`
	Atime  int64  `xorm:"notnull"`
	Mtime  int64  `xorm:"notnull"`
	Ctime  int64  `xorm:"notnull"`
	Nlink  uint32 `xorm:"notnull"`
	Length uint64 `xorm:"notnull"`
	Rdev   uint32
	Parent Ino
}

type edge struct {
	Id     int64  `xorm:"pk bigserial"`
	Parent Ino    `xorm:"unique(edge) notnull"`
	Name   []byte `xorm:"unique(edge) varbinary(255) notnull"`
	Inode  Ino    `xorm:"notnull"`
	Type   uint8  `xorm:"notnull"`
}

type namedNode struct {
	node `xorm:"extends"`
	Name []byte `xorm:"varbinary(255)"`
}

		s = s.Table(&edge{})
		nn := namedNode{node: node{Parent: parent}, Name: []byte(name)}
		s = s.Join("INNER", &node{}, "jfs_edge.inode=jfs_node.inode")
		exist, err := s.Select("jfs_node.*").Get(&nn)        

When it returns a row, but nn.node is empty

The following code is working with 1.0 and 1.1, but broken with 1.2+ ``` type node struct { Inode Ino `xorm:"pk"` Type uint8 `xorm:"notnull"` Flags uint8 `xorm:"notnull"` Mode uint16 `xorm:"notnull"` Uid uint32 `xorm:"notnull"` Gid uint32 `xorm:"notnull"` Atime int64 `xorm:"notnull"` Mtime int64 `xorm:"notnull"` Ctime int64 `xorm:"notnull"` Nlink uint32 `xorm:"notnull"` Length uint64 `xorm:"notnull"` Rdev uint32 Parent Ino } type edge struct { Id int64 `xorm:"pk bigserial"` Parent Ino `xorm:"unique(edge) notnull"` Name []byte `xorm:"unique(edge) varbinary(255) notnull"` Inode Ino `xorm:"notnull"` Type uint8 `xorm:"notnull"` } type namedNode struct { node `xorm:"extends"` Name []byte `xorm:"varbinary(255)"` } s = s.Table(&edge{}) nn := namedNode{node: node{Parent: parent}, Name: []byte(name)} s = s.Join("INNER", &node{}, "jfs_edge.inode=jfs_node.inode") exist, err := s.Select("jfs_node.*").Get(&nn) ``` When it returns a row, but `nn.node` is empty
Owner

Could you change the struct name with upper capital letter?

Could you change the struct name with upper capital letter?
Author

They are not public API, why they should be title case?

They are not public API, why they should be title case?
Owner

Since xorm is another package, it needs a public struct to read the fields.

Since xorm is another package, it needs a public struct to read the fields.
Sign in to join this conversation.
No Milestone
No Assignees
2 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#2148
No description provided.