Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
3694fe0f
Commit
3694fe0f
authored
Nov 24, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don’t quote `NOW()` for created_at column
To fix for MySQL.
parent
6e36452e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
3 deletions
+9
-3
lib/gitlab/background_migration/populate_untracked_uploads.rb
...gitlab/background_migration/populate_untracked_uploads.rb
+1
-1
lib/gitlab/database.rb
lib/gitlab/database.rb
+8
-2
No files found.
lib/gitlab/background_migration/populate_untracked_uploads.rb
View file @
3694fe0f
...
@@ -204,7 +204,7 @@ module Gitlab
...
@@ -204,7 +204,7 @@ module Gitlab
file
.
to_h
.
merge
(
created_at:
'NOW()'
)
file
.
to_h
.
merge
(
created_at:
'NOW()'
)
end
end
Gitlab
::
Database
.
bulk_insert
(
'uploads'
,
rows
)
Gitlab
::
Database
.
bulk_insert
(
'uploads'
,
rows
,
disable_quote: :created_at
)
end
end
def
drop_temp_table_if_finished
def
drop_temp_table_if_finished
...
...
lib/gitlab/database.rb
View file @
3694fe0f
...
@@ -116,15 +116,21 @@ module Gitlab
...
@@ -116,15 +116,21 @@ module Gitlab
# values.
# values.
# return_ids - When set to true the return value will be an Array of IDs of
# return_ids - When set to true the return value will be an Array of IDs of
# the inserted rows, this only works on PostgreSQL.
# the inserted rows, this only works on PostgreSQL.
def
self
.
bulk_insert
(
table
,
rows
,
return_ids:
false
)
# disable_quote - A key or an Array of keys to exclude from quoting (You
# become responsible for protection from SQL injection for
# these keys!)
def
self
.
bulk_insert
(
table
,
rows
,
return_ids:
false
,
disable_quote:
[])
return
if
rows
.
empty?
return
if
rows
.
empty?
keys
=
rows
.
first
.
keys
keys
=
rows
.
first
.
keys
columns
=
keys
.
map
{
|
key
|
connection
.
quote_column_name
(
key
)
}
columns
=
keys
.
map
{
|
key
|
connection
.
quote_column_name
(
key
)
}
return_ids
=
false
if
mysql?
return_ids
=
false
if
mysql?
disable_quote
=
Array
(
disable_quote
).
to_set
tuples
=
rows
.
map
do
|
row
|
tuples
=
rows
.
map
do
|
row
|
row
.
values_at
(
*
keys
).
map
{
|
value
|
connection
.
quote
(
value
)
}
row
.
keys
.
map
do
|
k
|
disable_quote
.
include?
(
k
)
?
row
[
k
]
:
connection
.
quote
(
row
[
k
])
end
end
end
sql
=
<<-
EOF
sql
=
<<-
EOF
...
...
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