package cursor import ( "testing" "time" "github.com/go-jet/jet/v2/mysql" ) var ( User = newUserTable("", "user", "") Address = newAddressTable("", "address", "") Meeting = newMeetingTable("", "meeting", "") MeetingRoom = newMeetingRoomTable("", "meeting_room", "") Scratch = newScratchTable("", "scratch", "") Spare = newSpareTable("", "spare", "") ) type userTable struct { mysql.Table ID mysql.ColumnInteger CreatedAt mysql.ColumnTimestamp AllColumns mysql.ColumnList } func newUserTable(schemaName, tableName, alias string) userTable { idCol := mysql.IntegerColumn("id") createdAtCol := mysql.TimestampColumn("created_at") allColumns := mysql.ColumnList{idCol, createdAtCol} return userTable{ Table: mysql.NewTable(schemaName, tableName, alias, allColumns...), ID: idCol, CreatedAt: createdAtCol, AllColumns: allColumns, } } type addressTable struct { mysql.Table ID mysql.ColumnInteger AllColumns mysql.ColumnList } func newAddressTable(schemaName, tableName, alias string) addressTable { idCol := mysql.IntegerColumn("id") allColumns := mysql.ColumnList{idCol} return addressTable{ Table: mysql.NewTable(schemaName, tableName, alias, allColumns...), ID: idCol, AllColumns: allColumns, } } type meetingTable struct { mysql.Table ID mysql.ColumnString StartTime mysql.ColumnTimestamp AllColumns mysql.ColumnList } func newMeetingTable(schemaName, tableName, alias string) meetingTable { idCol := mysql.StringColumn("id") startTimeCol := mysql.TimestampColumn("start_time") allColumns := mysql.ColumnList{idCol, startTimeCol} return meetingTable{ Table: mysql.NewTable(schemaName, tableName, alias, allColumns...), ID: idCol, StartTime: startTimeCol, AllColumns: allColumns, } } type meetingRoomTable struct { mysql.Table ID mysql.ColumnString AllColumns mysql.ColumnList } func newMeetingRoomTable(schemaName, tableName, alias string) meetingRoomTable { idCol := mysql.StringColumn("id") allColumns := mysql.ColumnList{idCol} return meetingRoomTable{ Table: mysql.NewTable(schemaName, tableName, alias, allColumns...), ID: idCol, AllColumns: allColumns, } } type scratchTable struct { mysql.Table ID mysql.ColumnInteger AllColumns mysql.ColumnList } func newScratchTable(schemaName, tableName, alias string) scratchTable { idCol := mysql.IntegerColumn("id") allColumns := mysql.ColumnList{idCol} return scratchTable{ Table: mysql.NewTable(schemaName, tableName, alias, allColumns...), ID: idCol, AllColumns: allColumns, } } type spareTable struct { mysql.Table ID mysql.ColumnInteger AllColumns mysql.ColumnList } func newSpareTable(schemaName, tableName, alias string) spareTable { idCol := mysql.IntegerColumn("id") allColumns := mysql.ColumnList{idCol} return spareTable{ Table: mysql.NewTable(schemaName, tableName, alias, allColumns...), ID: idCol, AllColumns: allColumns, } } func registerMeetingCursorColumns(t *testing.T) { t.Helper() RegisterColumn(Meeting.ID, Meeting.StartTime) } func mysqlSELECTWhere(cond mysql.BoolExpression) mysql.SelectStatement { return Meeting.SELECT(Meeting.AllColumns).WHERE(cond) } func mustTime(s string) time.Time { t, err := time.Parse(time.RFC3339, s) if err != nil { panic(err) } return t }