Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
8e5e72fc
You need to sign in or sign up before continuing.
Commit
8e5e72fc
authored
Aug 29, 2011
by
Stephanie Daugherty
Committed by
Max Kanat-Alexander
Aug 29, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 637648 - Rename the "tags" table to "tag"
r=LpSolit, a=LpSolit
parent
dd0e1c27
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
17 deletions
+45
-17
Bug.pm
Bugzilla/Bug.pm
+4
-4
DB.pm
Bugzilla/DB.pm
+11
-3
Schema.pm
Bugzilla/DB/Schema.pm
+3
-3
Sqlite.pm
Bugzilla/DB/Sqlite.pm
+4
-0
DB.pm
Bugzilla/Install/DB.pm
+18
-2
Search.pm
Bugzilla/Search.pm
+2
-2
User.pm
Bugzilla/User.pm
+2
-2
field-descs.none.tmpl
template/en/default/global/field-descs.none.tmpl
+1
-1
No files found.
Bugzilla/Bug.pm
View file @
8e5e72fc
...
@@ -2958,10 +2958,10 @@ sub add_tag {
...
@@ -2958,10 +2958,10 @@ sub add_tag {
my
$tag_id
=
$user
->
tags
->
{
$tag
}
->
{
id
};
my
$tag_id
=
$user
->
tags
->
{
$tag
}
->
{
id
};
# If this tag doesn't exist for this user yet, create it.
# If this tag doesn't exist for this user yet, create it.
if
(
!
$tag_id
)
{
if
(
!
$tag_id
)
{
$dbh
->
do
(
'INSERT INTO tag
s
(user_id, name) VALUES (?, ?)'
,
$dbh
->
do
(
'INSERT INTO tag (user_id, name) VALUES (?, ?)'
,
undef
,
(
$user
->
id
,
$tag
));
undef
,
(
$user
->
id
,
$tag
));
$tag_id
=
$dbh
->
selectrow_array
(
'SELECT id FROM tag
s
$tag_id
=
$dbh
->
selectrow_array
(
'SELECT id FROM tag
WHERE name = ? AND user_id = ?'
,
WHERE name = ? AND user_id = ?'
,
undef
,
(
$tag
,
$user
->
id
));
undef
,
(
$tag
,
$user
->
id
));
# The list has changed.
# The list has changed.
...
@@ -2997,7 +2997,7 @@ sub remove_tag {
...
@@ -2997,7 +2997,7 @@ sub remove_tag {
# Decrement the counter, and delete the tag if no bugs are using it anymore.
# Decrement the counter, and delete the tag if no bugs are using it anymore.
if
(
!--
$user
->
tags
->
{
$tag
}
->
{
bug_count
})
{
if
(
!--
$user
->
tags
->
{
$tag
}
->
{
bug_count
})
{
$dbh
->
do
(
'DELETE FROM tag
s
WHERE name = ? AND user_id = ?'
,
$dbh
->
do
(
'DELETE FROM tag WHERE name = ? AND user_id = ?'
,
undef
,
(
$tag
,
$user
->
id
));
undef
,
(
$tag
,
$user
->
id
));
# The list has changed.
# The list has changed.
...
@@ -3014,7 +3014,7 @@ sub tags {
...
@@ -3014,7 +3014,7 @@ sub tags {
if
(
!
exists
$self
->
{
tags
})
{
if
(
!
exists
$self
->
{
tags
})
{
$self
->
{
tags
}
=
$dbh
->
selectcol_arrayref
(
$self
->
{
tags
}
=
$dbh
->
selectcol_arrayref
(
'SELECT name FROM bug_tag
'SELECT name FROM bug_tag
INNER JOIN tag
s ON tags
.id = bug_tag.tag_id
INNER JOIN tag
ON tag
.id = bug_tag.tag_id
WHERE bug_id = ? AND user_id = ?'
,
WHERE bug_id = ? AND user_id = ?'
,
undef
,
(
$self
->
id
,
$user
->
id
));
undef
,
(
$self
->
id
,
$user
->
id
));
}
}
...
...
Bugzilla/DB.pm
View file @
8e5e72fc
...
@@ -93,6 +93,12 @@ use constant FULLTEXT_OR => '';
...
@@ -93,6 +93,12 @@ use constant FULLTEXT_OR => '';
use
constant
WORD_START
=>
'(^|[^[:alnum:]])'
;
use
constant
WORD_START
=>
'(^|[^[:alnum:]])'
;
use
constant
WORD_END
=>
'($|[^[:alnum:]])'
;
use
constant
WORD_END
=>
'($|[^[:alnum:]])'
;
# On most databases, in order to drop an index, you have to first drop
# the foreign keys that use that index. However, on some databases,
# dropping the FK immediately before dropping the index causes problems
# and doesn't need to be done anyway, so those DBs set this to 0.
use
constant
INDEX_DROPS_REQUIRE_FK_DROPS
=>
1
;
#####################################################################
#####################################################################
# Overridden Superclass Methods
# Overridden Superclass Methods
#####################################################################
#####################################################################
...
@@ -947,9 +953,11 @@ sub bz_drop_index {
...
@@ -947,9 +953,11 @@ sub bz_drop_index {
my
$index_exists
=
$self
->
bz_index_info
(
$table
,
$name
);
my
$index_exists
=
$self
->
bz_index_info
(
$table
,
$name
);
if
(
$index_exists
)
{
if
(
$index_exists
)
{
# We cannot delete an index used by a FK.
if
(
$self
->
INDEX_DROPS_REQUIRE_FK_DROPS
)
{
foreach
my
$column
(
@
{
$index_exists
->
{
FIELDS
}})
{
# We cannot delete an index used by a FK.
$self
->
bz_drop_related_fks
(
$table
,
$column
);
foreach
my
$column
(
@
{
$index_exists
->
{
FIELDS
}})
{
$self
->
bz_drop_related_fks
(
$table
,
$column
);
}
}
}
$self
->
bz_drop_index_raw
(
$table
,
$name
);
$self
->
bz_drop_index_raw
(
$table
,
$name
);
$self
->
_bz_real_schema
->
delete_index
(
$table
,
$name
);
$self
->
_bz_real_schema
->
delete_index
(
$table
,
$name
);
...
...
Bugzilla/DB/Schema.pm
View file @
8e5e72fc
...
@@ -1000,7 +1000,7 @@ use constant ABSTRACT_SCHEMA => {
...
@@ -1000,7 +1000,7 @@ use constant ABSTRACT_SCHEMA => {
],
],
},
},
tag
s
=>
{
tag
=>
{
FIELDS
=>
[
FIELDS
=>
[
id
=>
{
TYPE
=>
'MEDIUMSERIAL'
,
NOTNULL
=>
1
,
PRIMARYKEY
=>
1
},
id
=>
{
TYPE
=>
'MEDIUMSERIAL'
,
NOTNULL
=>
1
,
PRIMARYKEY
=>
1
},
name
=>
{
TYPE
=>
'varchar(64)'
,
NOTNULL
=>
1
},
name
=>
{
TYPE
=>
'varchar(64)'
,
NOTNULL
=>
1
},
...
@@ -1010,7 +1010,7 @@ use constant ABSTRACT_SCHEMA => {
...
@@ -1010,7 +1010,7 @@ use constant ABSTRACT_SCHEMA => {
DELETE
=>
'CASCADE'
}},
DELETE
=>
'CASCADE'
}},
],
],
INDEXES
=>
[
INDEXES
=>
[
tag
s
_user_id_idx
=>
{
FIELDS
=>
[
qw(user_id name)
],
TYPE
=>
'UNIQUE'
},
tag_user_id_idx
=>
{
FIELDS
=>
[
qw(user_id name)
],
TYPE
=>
'UNIQUE'
},
],
],
},
},
...
@@ -1021,7 +1021,7 @@ use constant ABSTRACT_SCHEMA => {
...
@@ -1021,7 +1021,7 @@ use constant ABSTRACT_SCHEMA => {
COLUMN
=>
'bug_id'
,
COLUMN
=>
'bug_id'
,
DELETE
=>
'CASCADE'
}},
DELETE
=>
'CASCADE'
}},
tag_id
=>
{
TYPE
=>
'INT3'
,
NOTNULL
=>
1
,
tag_id
=>
{
TYPE
=>
'INT3'
,
NOTNULL
=>
1
,
REFERENCES
=>
{
TABLE
=>
'tag
s
'
,
REFERENCES
=>
{
TABLE
=>
'tag'
,
COLUMN
=>
'id'
,
COLUMN
=>
'id'
,
DELETE
=>
'CASCADE'
}},
DELETE
=>
'CASCADE'
}},
],
],
...
...
Bugzilla/DB/Sqlite.pm
View file @
8e5e72fc
...
@@ -39,6 +39,10 @@ use constant ISOLATION_LEVEL => undef;
...
@@ -39,6 +39,10 @@ use constant ISOLATION_LEVEL => undef;
use
constant
WORD_START
=>
'(?:^|\W)'
;
use
constant
WORD_START
=>
'(?:^|\W)'
;
use
constant
WORD_END
=>
'(?:$|\W)'
;
use
constant
WORD_END
=>
'(?:$|\W)'
;
# For some reason, dropping the related FKs causes the index to
# disappear early, which causes all sorts of problems.
use
constant
INDEX_DROPS_REQUIRE_FK_DROPS
=>
0
;
####################################
####################################
# Functions Added To SQLite Itself #
# Functions Added To SQLite Itself #
####################################
####################################
...
...
Bugzilla/Install/DB.pm
View file @
8e5e72fc
...
@@ -646,6 +646,8 @@ sub update_table_definitions {
...
@@ -646,6 +646,8 @@ sub update_table_definitions {
$dbh
->
bz_add_column
(
'bug_see_also'
,
'id'
,
$dbh
->
bz_add_column
(
'bug_see_also'
,
'id'
,
{
TYPE
=>
'MEDIUMSERIAL'
,
NOTNULL
=>
1
,
PRIMARYKEY
=>
1
});
{
TYPE
=>
'MEDIUMSERIAL'
,
NOTNULL
=>
1
,
PRIMARYKEY
=>
1
});
_rename_tags_to_tag
();
# 2011-01-29 LpSolit@gmail.com - Bug 616185
# 2011-01-29 LpSolit@gmail.com - Bug 616185
_migrate_user_tags
();
_migrate_user_tags
();
...
@@ -3485,9 +3487,9 @@ sub _migrate_user_tags {
...
@@ -3485,9 +3487,9 @@ sub _migrate_user_tags {
WHERE query_type != 0'
);
WHERE query_type != 0'
);
my
$sth_tags
=
$dbh
->
prepare
(
my
$sth_tags
=
$dbh
->
prepare
(
'INSERT INTO tag
s
(user_id, name) VALUES (?, ?)'
);
'INSERT INTO tag (user_id, name) VALUES (?, ?)'
);
my
$sth_tag_id
=
$dbh
->
prepare
(
my
$sth_tag_id
=
$dbh
->
prepare
(
'SELECT id FROM tag
s
WHERE user_id = ? AND name = ?'
);
'SELECT id FROM tag WHERE user_id = ? AND name = ?'
);
my
$sth_bug_tag
=
$dbh
->
prepare
(
'INSERT INTO bug_tag (bug_id, tag_id)
my
$sth_bug_tag
=
$dbh
->
prepare
(
'INSERT INTO bug_tag (bug_id, tag_id)
VALUES (?, ?)'
);
VALUES (?, ?)'
);
my
$sth_nq
=
$dbh
->
prepare
(
'UPDATE namedqueries SET query = ?
my
$sth_nq
=
$dbh
->
prepare
(
'UPDATE namedqueries SET query = ?
...
@@ -3586,6 +3588,20 @@ sub _migrate_disabledtext_boolean {
...
@@ -3586,6 +3588,20 @@ sub _migrate_disabledtext_boolean {
}
}
}
}
sub
_rename_tags_to_tag
{
my
$dbh
=
Bugzilla
->
dbh
;
if
(
$dbh
->
bz_table_info
(
'tags'
))
{
# If we get here, it's because the schema created "tag" as an empty
# table while "tags" still exists. We get rid of the empty
# tag table so we can do the rename over the top of it.
$dbh
->
bz_drop_table
(
'tag'
);
$dbh
->
bz_drop_index
(
'tags'
,
'tags_user_id_idx'
);
$dbh
->
bz_rename_table
(
'tags'
,
'tag'
);
$dbh
->
bz_add_index
(
'tag'
,
'tag_user_id_idx'
,
{
FIELDS
=>
[
qw(user_id name)
],
TYPE
=>
'UNIQUE'
});
}
}
1
;
1
;
__END__
__END__
...
...
Bugzilla/Search.pm
View file @
8e5e72fc
...
@@ -2525,8 +2525,8 @@ sub _multiselect_table {
...
@@ -2525,8 +2525,8 @@ sub _multiselect_table {
" ON keywords.keywordid = keyworddefs.id"
;
" ON keywords.keywordid = keyworddefs.id"
;
}
}
elsif
(
$field
eq
'tag'
)
{
elsif
(
$field
eq
'tag'
)
{
$args
->
{
full_field
}
=
'tag
s
.name'
;
$args
->
{
full_field
}
=
'tag.name'
;
return
"bug_tag INNER JOIN tag
s ON bug_tag.tag_id = tags
.id"
return
"bug_tag INNER JOIN tag
ON bug_tag.tag_id = tag
.id"
.
" AND user_id = "
.
$self
->
_user
->
id
;
.
" AND user_id = "
.
$self
->
_user
->
id
;
}
}
elsif
(
$field
eq
'bug_group'
)
{
elsif
(
$field
eq
'bug_group'
)
{
...
...
Bugzilla/User.pm
View file @
8e5e72fc
...
@@ -423,8 +423,8 @@ sub tags {
...
@@ -423,8 +423,8 @@ sub tags {
# in which case there are no bugs with this tag yet.
# in which case there are no bugs with this tag yet.
$self
->
{
tags
}
=
$dbh
->
selectall_hashref
(
$self
->
{
tags
}
=
$dbh
->
selectall_hashref
(
'SELECT name, id, COUNT(bug_id) AS bug_count
'SELECT name, id, COUNT(bug_id) AS bug_count
FROM tag
s
FROM tag
LEFT JOIN bug_tag ON bug_tag.tag_id = tag
s
.id
LEFT JOIN bug_tag ON bug_tag.tag_id = tag.id
WHERE user_id = ? '
.
$dbh
->
sql_group_by
(
'id'
,
'name'
),
WHERE user_id = ? '
.
$dbh
->
sql_group_by
(
'id'
,
'name'
),
'name'
,
undef
,
$self
->
id
);
'name'
,
undef
,
$self
->
id
);
}
}
...
...
template/en/default/global/field-descs.none.tmpl
View file @
8e5e72fc
...
@@ -133,7 +133,7 @@
...
@@ -133,7 +133,7 @@
"settings" => "Settings",
"settings" => "Settings",
"short_desc" => "Summary",
"short_desc" => "Summary",
"status_whiteboard" => "Whiteboard",
"status_whiteboard" => "Whiteboard",
"tag
s.name"
=> "Tags",
"tag
.name"
=> "Tags",
"target_milestone" => "Target Milestone",
"target_milestone" => "Target Milestone",
"version" => "Version",
"version" => "Version",
"work_time" => "Hours Worked",
"work_time" => "Hours Worked",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment