Model and table structure mismatch? #8894

Closed
opened 2025-11-02 08:22:18 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @wxiaoguang on GitHub (May 2, 2022).

For example:

// TrackedTime represents a time that was spent for a specific issue.
type TrackedTime struct {
	...
	Created     time.Time        `xorm:"-"`
	CreatedUnix int64            `xorm:"created"`
}

In database (MySQL / SQLite):

CREATE TABLE `tracked_time` (
	...
	`created_unix` bigint DEFAULT NULL,
);

IIRC CreatedUnix int64 `xorm:"created"` means that the column name should be created, is it an undocumented/documented behavior, or bug, or I missed something?

Originally created by @wxiaoguang on GitHub (May 2, 2022). For example: ```golang // TrackedTime represents a time that was spent for a specific issue. type TrackedTime struct { ... Created time.Time `xorm:"-"` CreatedUnix int64 `xorm:"created"` } ``` In database (MySQL / SQLite): ```sql CREATE TABLE `tracked_time` ( ... `created_unix` bigint DEFAULT NULL, ); ``` IIRC `` CreatedUnix int64 `xorm:"created"` `` means that the column name should be `created`, is it an undocumented/documented behavior, or bug, or I missed something?
GiteaMirror added the type/question label 2025-11-02 08:22:18 -06:00
Author
Owner

@wxiaoguang commented on GitHub (May 2, 2022):

Learnt from discussion:

created is a XORM keyword, not a column name.

So the column name is CreatedUnix => created_unix (implicitly)

@wxiaoguang commented on GitHub (May 2, 2022): Learnt from discussion: `created` is a XORM keyword, not a column name. So the column name is `CreatedUnix` => `created_unix` (implicitly)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#8894