Ensure consistent naming of title fields (#528)
Remove task text and namespace name in migration Fix lint Add migration for namespace title Fix renaming namespace name to title Rename namespace name field to title Drop text column at the end of the migration Add migration for task text to title Rename task text to title Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/528
This commit is contained in:
@ -110,7 +110,7 @@ func (bt *BulkTask) Update() (err error) {
|
||||
}
|
||||
|
||||
_, err = sess.ID(oldtask.ID).
|
||||
Cols("text",
|
||||
Cols("title",
|
||||
"description",
|
||||
"done",
|
||||
"due_date_unix",
|
||||
|
@ -24,7 +24,7 @@ func TestBulkTask_Update(t *testing.T) {
|
||||
fields: fields{
|
||||
IDs: []int64{10, 11, 12},
|
||||
Task: Task{
|
||||
Text: "bulkupdated",
|
||||
Title: "bulkupdated",
|
||||
},
|
||||
User: &user.User{ID: 1},
|
||||
},
|
||||
@ -34,7 +34,7 @@ func TestBulkTask_Update(t *testing.T) {
|
||||
fields: fields{
|
||||
IDs: []int64{10, 11, 12, 13},
|
||||
Task: Task{
|
||||
Text: "bulkupdated",
|
||||
Title: "bulkupdated",
|
||||
},
|
||||
User: &user.User{ID: 1},
|
||||
},
|
||||
@ -45,7 +45,7 @@ func TestBulkTask_Update(t *testing.T) {
|
||||
fields: fields{
|
||||
IDs: []int64{},
|
||||
Task: Task{
|
||||
Text: "bulkupdated",
|
||||
Title: "bulkupdated",
|
||||
},
|
||||
User: &user.User{ID: 1},
|
||||
},
|
||||
|
@ -268,7 +268,7 @@ func IsErrTaskCannotBeEmpty(err error) bool {
|
||||
}
|
||||
|
||||
func (err ErrTaskCannotBeEmpty) Error() string {
|
||||
return fmt.Sprintf("List task text cannot be empty.")
|
||||
return fmt.Sprintf("List task title cannot be empty.")
|
||||
}
|
||||
|
||||
// ErrCodeTaskCannotBeEmpty holds the unique world-error code of this error
|
||||
@ -276,7 +276,7 @@ const ErrCodeTaskCannotBeEmpty = 4001
|
||||
|
||||
// HTTPError holds the http error description
|
||||
func (err ErrTaskCannotBeEmpty) HTTPError() web.HTTPError {
|
||||
return web.HTTPError{HTTPCode: http.StatusBadRequest, Code: ErrCodeTaskCannotBeEmpty, Message: "You must provide at least a list task text."}
|
||||
return web.HTTPError{HTTPCode: http.StatusBadRequest, Code: ErrCodeTaskCannotBeEmpty, Message: "You must provide at least a list task title."}
|
||||
}
|
||||
|
||||
// ErrTaskDoesNotExist represents a "ErrListDoesNotExist" kind of error. Used if the list does not exist.
|
||||
|
@ -31,7 +31,7 @@ type Namespace struct {
|
||||
// The unique, numeric id of this namespace.
|
||||
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"namespace"`
|
||||
// The name of this namespace.
|
||||
Name string `xorm:"varchar(250) not null" json:"name" valid:"required,runelength(5|250)" minLength:"5" maxLength:"250"`
|
||||
Title string `xorm:"varchar(250) not null" json:"title" valid:"required,runelength(5|250)" minLength:"5" maxLength:"250"`
|
||||
// The description of the namespace
|
||||
Description string `xorm:"longtext null" json:"description"`
|
||||
OwnerID int64 `xorm:"int(11) not null INDEX" json:"-"`
|
||||
@ -57,7 +57,7 @@ type Namespace struct {
|
||||
// PseudoNamespace is a pseudo namespace used to hold shared lists
|
||||
var PseudoNamespace = Namespace{
|
||||
ID: -1,
|
||||
Name: "Shared Lists",
|
||||
Title: "Shared Lists",
|
||||
Description: "Lists of other users shared with you via teams or directly.",
|
||||
Created: timeutil.FromTime(time.Now()),
|
||||
Updated: timeutil.FromTime(time.Now()),
|
||||
@ -201,7 +201,7 @@ func (n *Namespace) ReadAll(a web.Auth, search string, page int, perPage int) (r
|
||||
Or("namespaces.owner_id = ?", doer.ID).
|
||||
Or("users_namespace.user_id = ?", doer.ID).
|
||||
GroupBy("namespaces.id").
|
||||
Where("namespaces.name LIKE ?", "%"+search+"%").
|
||||
Where("namespaces.title LIKE ?", "%"+search+"%").
|
||||
Where(isArchivedCond)
|
||||
if limit > 0 {
|
||||
query = query.Limit(limit, start)
|
||||
@ -301,7 +301,7 @@ func (n *Namespace) ReadAll(a web.Auth, search string, page int, perPage int) (r
|
||||
Or("users_namespace.user_id = ?", doer.ID).
|
||||
And("namespaces.is_archived = false").
|
||||
GroupBy("namespaces.id").
|
||||
Where("namespaces.name LIKE ?", "%"+search+"%").
|
||||
Where("namespaces.title LIKE ?", "%"+search+"%").
|
||||
Count(&NamespaceWithLists{})
|
||||
if err != nil {
|
||||
return all, 0, 0, err
|
||||
@ -325,7 +325,7 @@ func (n *Namespace) ReadAll(a web.Auth, search string, page int, perPage int) (r
|
||||
// @Router /namespaces [put]
|
||||
func (n *Namespace) Create(a web.Auth) (err error) {
|
||||
// Check if we have at least a name
|
||||
if n.Name == "" {
|
||||
if n.Title == "" {
|
||||
return ErrNamespaceNameCannotBeEmpty{NamespaceID: 0, UserID: a.GetID()}
|
||||
}
|
||||
n.ID = 0 // This would otherwise prevent the creation of new lists after one was created
|
||||
@ -418,7 +418,7 @@ func (n *Namespace) Delete() (err error) {
|
||||
// @Router /namespace/{id} [post]
|
||||
func (n *Namespace) Update() (err error) {
|
||||
// Check if we have at least a name
|
||||
if n.Name == "" {
|
||||
if n.Title == "" {
|
||||
return ErrNamespaceNameCannotBeEmpty{NamespaceID: n.ID}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ func TestNamespace_Create(t *testing.T) {
|
||||
|
||||
// Dummy namespace
|
||||
dummynamespace := Namespace{
|
||||
Name: "Test",
|
||||
Title: "Test",
|
||||
Description: "Lorem Ipsum",
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ func TestNamespace_Create(t *testing.T) {
|
||||
assert.True(t, allowed)
|
||||
err = dummynamespace.ReadOne()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, dummynamespace.Name, "Test")
|
||||
assert.Equal(t, dummynamespace.Title, "Test")
|
||||
|
||||
// Try creating one without a name
|
||||
n2 := Namespace{}
|
||||
@ -92,13 +92,13 @@ func TestNamespace_Create(t *testing.T) {
|
||||
assert.True(t, user.IsErrUserDoesNotExist(err))
|
||||
|
||||
// Try updating without a name
|
||||
dummynamespace.Name = ""
|
||||
dummynamespace.Title = ""
|
||||
err = dummynamespace.Update()
|
||||
assert.Error(t, err)
|
||||
assert.True(t, IsErrNamespaceNameCannotBeEmpty(err))
|
||||
|
||||
// Try updating a nonexistant one
|
||||
n := Namespace{ID: 284729, Name: "Lorem"}
|
||||
n := Namespace{ID: 284729, Title: "Lorem"}
|
||||
err = n.Update()
|
||||
assert.Error(t, err)
|
||||
assert.True(t, IsErrNamespaceDoesNotExist(err))
|
||||
|
@ -54,7 +54,7 @@ func validateTaskField(fieldName string) error {
|
||||
switch fieldName {
|
||||
case
|
||||
taskPropertyID,
|
||||
taskPropertyText,
|
||||
taskPropertyTitle,
|
||||
taskPropertyDescription,
|
||||
taskPropertyDone,
|
||||
taskPropertyDoneAtUnix,
|
||||
@ -87,7 +87,7 @@ func validateTaskField(fieldName string) error {
|
||||
// @Param page query int false "The page number. Used for pagination. If not provided, the first page of results is returned."
|
||||
// @Param per_page query int false "The maximum number of items per page. Note this parameter is limited by the configured maximum of items per page."
|
||||
// @Param s query string false "Search tasks by task text."
|
||||
// @Param sort_by query string false "The sorting parameter. You can pass this multiple times to get the tasks ordered by multiple different parametes, along with `order_by`. Possible values to sort by are `id`, `text`, `description`, `done`, `done_at_unix`, `due_date_unix`, `created_by_id`, `list_id`, `repeat_after`, `priority`, `start_date_unix`, `end_date_unix`, `hex_color`, `percent_done`, `uid`, `created`, `updated`. Default is `id`."
|
||||
// @Param sort_by query string false "The sorting parameter. You can pass this multiple times to get the tasks ordered by multiple different parametes, along with `order_by`. Possible values to sort by are `id`, `title`, `description`, `done`, `done_at_unix`, `due_date_unix`, `created_by_id`, `list_id`, `repeat_after`, `priority`, `start_date_unix`, `end_date_unix`, `hex_color`, `percent_done`, `uid`, `created`, `updated`. Default is `id`."
|
||||
// @Param order_by query string false "The ordering parameter. Possible values to order by are `asc` or `desc`. Default is `asc`."
|
||||
// @Param filter_by query string false "The name of the field to filter by. Accepts an array for multiple filters which will be chanied together, all supplied filter must match."
|
||||
// @Param filter_value query string false "The value to filter for."
|
||||
|
@ -27,7 +27,7 @@ type (
|
||||
|
||||
const (
|
||||
taskPropertyID string = "id"
|
||||
taskPropertyText string = "text"
|
||||
taskPropertyTitle string = "title"
|
||||
taskPropertyDescription string = "description"
|
||||
taskPropertyDone string = "done"
|
||||
taskPropertyDoneAtUnix string = "done_at_unix"
|
||||
|
@ -43,7 +43,7 @@ func TestSortParamValidation(t *testing.T) {
|
||||
t.Run("Test valid sort by", func(t *testing.T) {
|
||||
for _, test := range []string{
|
||||
taskPropertyID,
|
||||
taskPropertyText,
|
||||
taskPropertyTitle,
|
||||
taskPropertyDescription,
|
||||
taskPropertyDone,
|
||||
taskPropertyDoneAtUnix,
|
||||
|
@ -49,7 +49,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
// We use individual variables for the tasks here to be able to rearrange or remove ones more easily
|
||||
task1 := &Task{
|
||||
ID: 1,
|
||||
Text: "task #1",
|
||||
Title: "task #1",
|
||||
Description: "Lorem Ipsum",
|
||||
Identifier: "test1-1",
|
||||
Index: 1,
|
||||
@ -71,7 +71,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
RelationKindSubtask: {
|
||||
{
|
||||
ID: 29,
|
||||
Text: "task #29 with parent task (1)",
|
||||
Title: "task #29 with parent task (1)",
|
||||
Index: 14,
|
||||
CreatedByID: 1,
|
||||
ListID: 1,
|
||||
@ -109,7 +109,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task2 := &Task{
|
||||
ID: 2,
|
||||
Text: "task #2 done",
|
||||
Title: "task #2 done",
|
||||
Identifier: "test1-2",
|
||||
Index: 2,
|
||||
Done: true,
|
||||
@ -133,7 +133,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task3 := &Task{
|
||||
ID: 3,
|
||||
Text: "task #3 high prio",
|
||||
Title: "task #3 high prio",
|
||||
Identifier: "test1-3",
|
||||
Index: 3,
|
||||
CreatedByID: 1,
|
||||
@ -147,7 +147,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task4 := &Task{
|
||||
ID: 4,
|
||||
Text: "task #4 low prio",
|
||||
Title: "task #4 low prio",
|
||||
Identifier: "test1-4",
|
||||
Index: 4,
|
||||
CreatedByID: 1,
|
||||
@ -161,7 +161,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task5 := &Task{
|
||||
ID: 5,
|
||||
Text: "task #5 higher due date",
|
||||
Title: "task #5 higher due date",
|
||||
Identifier: "test1-5",
|
||||
Index: 5,
|
||||
CreatedByID: 1,
|
||||
@ -175,7 +175,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task6 := &Task{
|
||||
ID: 6,
|
||||
Text: "task #6 lower due date",
|
||||
Title: "task #6 lower due date",
|
||||
Identifier: "test1-6",
|
||||
Index: 6,
|
||||
CreatedByID: 1,
|
||||
@ -189,7 +189,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task7 := &Task{
|
||||
ID: 7,
|
||||
Text: "task #7 with start date",
|
||||
Title: "task #7 with start date",
|
||||
Identifier: "test1-7",
|
||||
Index: 7,
|
||||
CreatedByID: 1,
|
||||
@ -203,7 +203,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task8 := &Task{
|
||||
ID: 8,
|
||||
Text: "task #8 with end date",
|
||||
Title: "task #8 with end date",
|
||||
Identifier: "test1-8",
|
||||
Index: 8,
|
||||
CreatedByID: 1,
|
||||
@ -217,7 +217,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task9 := &Task{
|
||||
ID: 9,
|
||||
Text: "task #9 with start and end date",
|
||||
Title: "task #9 with start and end date",
|
||||
Identifier: "test1-9",
|
||||
Index: 9,
|
||||
CreatedByID: 1,
|
||||
@ -232,7 +232,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task10 := &Task{
|
||||
ID: 10,
|
||||
Text: "task #10 basic",
|
||||
Title: "task #10 basic",
|
||||
Identifier: "test1-10",
|
||||
Index: 10,
|
||||
CreatedByID: 1,
|
||||
@ -245,7 +245,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task11 := &Task{
|
||||
ID: 11,
|
||||
Text: "task #11 basic",
|
||||
Title: "task #11 basic",
|
||||
Identifier: "test1-11",
|
||||
Index: 11,
|
||||
CreatedByID: 1,
|
||||
@ -258,7 +258,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task12 := &Task{
|
||||
ID: 12,
|
||||
Text: "task #12 basic",
|
||||
Title: "task #12 basic",
|
||||
Identifier: "test1-12",
|
||||
Index: 12,
|
||||
CreatedByID: 1,
|
||||
@ -271,7 +271,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task15 := &Task{
|
||||
ID: 15,
|
||||
Text: "task #15",
|
||||
Title: "task #15",
|
||||
Identifier: "test6-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -284,7 +284,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task16 := &Task{
|
||||
ID: 16,
|
||||
Text: "task #16",
|
||||
Title: "task #16",
|
||||
Identifier: "test7-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -297,7 +297,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task17 := &Task{
|
||||
ID: 17,
|
||||
Text: "task #17",
|
||||
Title: "task #17",
|
||||
Identifier: "test8-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -310,7 +310,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task18 := &Task{
|
||||
ID: 18,
|
||||
Text: "task #18",
|
||||
Title: "task #18",
|
||||
Identifier: "test9-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -323,7 +323,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task19 := &Task{
|
||||
ID: 19,
|
||||
Text: "task #19",
|
||||
Title: "task #19",
|
||||
Identifier: "test10-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -336,7 +336,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task20 := &Task{
|
||||
ID: 20,
|
||||
Text: "task #20",
|
||||
Title: "task #20",
|
||||
Identifier: "test11-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -349,7 +349,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task21 := &Task{
|
||||
ID: 21,
|
||||
Text: "task #21",
|
||||
Title: "task #21",
|
||||
Identifier: "test12-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -362,7 +362,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task22 := &Task{
|
||||
ID: 22,
|
||||
Text: "task #22",
|
||||
Title: "task #22",
|
||||
Identifier: "test13-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -375,7 +375,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task23 := &Task{
|
||||
ID: 23,
|
||||
Text: "task #23",
|
||||
Title: "task #23",
|
||||
Identifier: "test14-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -388,7 +388,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task24 := &Task{
|
||||
ID: 24,
|
||||
Text: "task #24",
|
||||
Title: "task #24",
|
||||
Identifier: "test15-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -401,7 +401,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task25 := &Task{
|
||||
ID: 25,
|
||||
Text: "task #25",
|
||||
Title: "task #25",
|
||||
Identifier: "test16-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -414,7 +414,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task26 := &Task{
|
||||
ID: 26,
|
||||
Text: "task #26",
|
||||
Title: "task #26",
|
||||
Identifier: "test17-1",
|
||||
Index: 1,
|
||||
CreatedByID: 6,
|
||||
@ -427,7 +427,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task27 := &Task{
|
||||
ID: 27,
|
||||
Text: "task #27 with reminders",
|
||||
Title: "task #27 with reminders",
|
||||
Identifier: "test1-12",
|
||||
Index: 12,
|
||||
CreatedByID: 1,
|
||||
@ -441,7 +441,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task28 := &Task{
|
||||
ID: 28,
|
||||
Text: "task #28 with repeat after",
|
||||
Title: "task #28 with repeat after",
|
||||
Identifier: "test1-13",
|
||||
Index: 13,
|
||||
CreatedByID: 1,
|
||||
@ -455,7 +455,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task29 := &Task{
|
||||
ID: 29,
|
||||
Text: "task #29 with parent task (1)",
|
||||
Title: "task #29 with parent task (1)",
|
||||
Identifier: "test1-14",
|
||||
Index: 14,
|
||||
CreatedByID: 1,
|
||||
@ -465,7 +465,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
RelationKindParenttask: {
|
||||
{
|
||||
ID: 1,
|
||||
Text: "task #1",
|
||||
Title: "task #1",
|
||||
Description: "Lorem Ipsum",
|
||||
Index: 1,
|
||||
CreatedByID: 1,
|
||||
@ -482,7 +482,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task30 := &Task{
|
||||
ID: 30,
|
||||
Text: "task #30 with assignees",
|
||||
Title: "task #30 with assignees",
|
||||
Identifier: "test1-15",
|
||||
Index: 15,
|
||||
CreatedByID: 1,
|
||||
@ -499,7 +499,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task31 := &Task{
|
||||
ID: 31,
|
||||
Text: "task #31 with color",
|
||||
Title: "task #31 with color",
|
||||
Identifier: "test1-16",
|
||||
Index: 16,
|
||||
HexColor: "f0f0f0",
|
||||
@ -513,7 +513,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task32 := &Task{
|
||||
ID: 32,
|
||||
Text: "task #32",
|
||||
Title: "task #32",
|
||||
Identifier: "test3-1",
|
||||
Index: 1,
|
||||
CreatedByID: 1,
|
||||
@ -526,7 +526,7 @@ func TestTaskCollection_ReadAll(t *testing.T) {
|
||||
}
|
||||
task33 := &Task{
|
||||
ID: 33,
|
||||
Text: "task #33 with percent done",
|
||||
Title: "task #33 with percent done",
|
||||
Identifier: "test1-17",
|
||||
Index: 17,
|
||||
CreatedByID: 1,
|
||||
|
@ -37,7 +37,7 @@ type Task struct {
|
||||
// The unique, numeric id of this task.
|
||||
ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id" param:"listtask"`
|
||||
// The task text. This is what you'll see in the list.
|
||||
Text string `xorm:"varchar(250) not null" json:"text" valid:"runelength(3|250)" minLength:"3" maxLength:"250"`
|
||||
Title string `xorm:"varchar(250) not null" json:"title" valid:"runelength(3|250)" minLength:"3" maxLength:"250"`
|
||||
// The task description.
|
||||
Description string `xorm:"longtext null" json:"description"`
|
||||
// Whether a task is done or not.
|
||||
@ -242,11 +242,11 @@ func getRawTasksForLists(lists []*List, opts *taskOptions) (tasks []*Task, resul
|
||||
// See https://stackoverflow.com/q/7005302/10924593
|
||||
// Seems okay to use that now, we may need to find a better solution overall in the future.
|
||||
if config.DatabaseType.GetString() == "postgres" {
|
||||
query = query.Where("text ILIKE ?", "%"+opts.search+"%")
|
||||
queryCount = queryCount.Where("text ILIKE ?", "%"+opts.search+"%")
|
||||
query = query.Where("title ILIKE ?", "%"+opts.search+"%")
|
||||
queryCount = queryCount.Where("title ILIKE ?", "%"+opts.search+"%")
|
||||
} else {
|
||||
query = query.Where("text LIKE ?", "%"+opts.search+"%")
|
||||
queryCount = queryCount.Where("text LIKE ?", "%"+opts.search+"%")
|
||||
query = query.Where("title LIKE ?", "%"+opts.search+"%")
|
||||
queryCount = queryCount.Where("title LIKE ?", "%"+opts.search+"%")
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,7 +554,7 @@ func (t *Task) Create(a web.Auth) (err error) {
|
||||
t.ID = 0
|
||||
|
||||
// Check if we have at least a text
|
||||
if t.Text == "" {
|
||||
if t.Title == "" {
|
||||
return ErrTaskCannotBeEmpty{}
|
||||
}
|
||||
|
||||
@ -758,7 +758,7 @@ func (t *Task) Update() (err error) {
|
||||
}
|
||||
|
||||
_, err = x.ID(t.ID).
|
||||
Cols("text",
|
||||
Cols("title",
|
||||
"description",
|
||||
"done",
|
||||
"due_date_unix",
|
||||
|
@ -36,7 +36,7 @@ func TestTask_Create(t *testing.T) {
|
||||
t.Run("normal", func(t *testing.T) {
|
||||
db.LoadAndAssertFixtures(t)
|
||||
task := &Task{
|
||||
Text: "Lorem",
|
||||
Title: "Lorem",
|
||||
Description: "Lorem Ipsum Dolor",
|
||||
ListID: 1,
|
||||
}
|
||||
@ -51,10 +51,10 @@ func TestTask_Create(t *testing.T) {
|
||||
assert.Equal(t, int64(1), task.BucketID)
|
||||
|
||||
})
|
||||
t.Run("empty text", func(t *testing.T) {
|
||||
t.Run("empty title", func(t *testing.T) {
|
||||
db.LoadAndAssertFixtures(t)
|
||||
task := &Task{
|
||||
Text: "",
|
||||
Title: "",
|
||||
Description: "Lorem Ipsum Dolor",
|
||||
ListID: 1,
|
||||
}
|
||||
@ -65,7 +65,7 @@ func TestTask_Create(t *testing.T) {
|
||||
t.Run("nonexistant list", func(t *testing.T) {
|
||||
db.LoadAndAssertFixtures(t)
|
||||
task := &Task{
|
||||
Text: "Test",
|
||||
Title: "Test",
|
||||
Description: "Lorem Ipsum Dolor",
|
||||
ListID: 9999999,
|
||||
}
|
||||
@ -77,7 +77,7 @@ func TestTask_Create(t *testing.T) {
|
||||
db.LoadAndAssertFixtures(t)
|
||||
nUser := &user.User{ID: 99999999}
|
||||
task := &Task{
|
||||
Text: "Test",
|
||||
Title: "Test",
|
||||
Description: "Lorem Ipsum Dolor",
|
||||
ListID: 1,
|
||||
}
|
||||
@ -92,7 +92,7 @@ func TestTask_Update(t *testing.T) {
|
||||
db.LoadAndAssertFixtures(t)
|
||||
task := &Task{
|
||||
ID: 1,
|
||||
Text: "test10000",
|
||||
Title: "test10000",
|
||||
Description: "Lorem Ipsum Dolor",
|
||||
ListID: 1,
|
||||
}
|
||||
@ -103,7 +103,7 @@ func TestTask_Update(t *testing.T) {
|
||||
db.LoadAndAssertFixtures(t)
|
||||
task := &Task{
|
||||
ID: 9999999,
|
||||
Text: "test10000",
|
||||
Title: "test10000",
|
||||
Description: "Lorem Ipsum Dolor",
|
||||
ListID: 1,
|
||||
}
|
||||
@ -215,7 +215,7 @@ func TestTask_ReadOne(t *testing.T) {
|
||||
task := &Task{ID: 1}
|
||||
err := task.ReadOne()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "task #1", task.Text)
|
||||
assert.Equal(t, "task #1", task.Title)
|
||||
})
|
||||
t.Run("nonexisting", func(t *testing.T) {
|
||||
db.LoadAndAssertFixtures(t)
|
||||
|
Reference in New Issue
Block a user