Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Mukul
erp5
Commits
5285a607
Commit
5285a607
authored
Sep 02, 2013
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make DA.upgradeSchema update table CHARSET/COLLATE default
parent
531d2963
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
5 deletions
+9
-5
product/ERP5Type/patches/DA.py
product/ERP5Type/patches/DA.py
+9
-5
No files found.
product/ERP5Type/patches/DA.py
View file @
5285a607
...
...
@@ -259,19 +259,21 @@ def DA__call__(self, REQUEST=None, __ick__=None, src__=0, test__=0, **kw):
def
_getTableSchema
(
query
,
name
,
create_lstrip
=
re
.
compile
(
r"[^(]+\
(
\s*"
).
sub
,
create_rstrip
=
re
.
compile
(
r"\
s*
\)[^)]+$"
).
sub
,
create_rmatch
=
re
.
compile
(
r"(.*\
S)
\s*\
)[^)]+
\s"
"(DEFAULT(
\
s+(CHARSET|COLLATE)=
\
S+)+).*$"
,
re
.
DOTALL
).
match
,
create_split
=
re
.
compile
(
r",\n\
s*
").split,
column_match = re.compile(r"
`(\w+)`
\
s
+
(.
+
)
").match,
):
(_, schema), = query("
SHOW
CREATE
TABLE
" + name)[1]
column_list = []
key_set = set()
for spec in create_split(create_rstrip("", create_lstrip("", schema, 1))):
m = create_rmatch(create_lstrip("", schema, 1))
for spec in create_split(m.group(1)):
if "
KEY
" in spec:
key_set.add(spec)
else:
column_list.append(column_match(spec).groups())
return column_list, key_set
return column_list, key_set
, m.group(2)
_create_search = re.compile(r'
\
b
CREATE
\
s+TABLE
\
s+(`?)(
\
w+)
\
1
\
s+
'
, re.I).search
_key_search = re.compile(r'
\
b
KEY
\
s+(`[^`]+`)
\
s+(.+)').search
...
...
@@ -284,17 +286,19 @@ def DA_upgradeSchema(self, connection_id=None, src__=0):
return
name = m.group(2)
old_list, old_set = _getTableSchema(query, name)
old_list, old_set
, old_default
= _getTableSchema(query, name)
name_new = '_%s_new' % name
query('CREATE TEMPORARY TABLE %s %s' % (name_new, src[m.end():]))
try:
new_list, new_set = _getTableSchema(query, name_new)
new_list, new_set
, new_default
= _getTableSchema(query, name_new)
finally:
query("
DROP
TEMPORARY
TABLE
" + name_new)
src = []
q = src.append
if old_default != new_default:
q(new_default)
old_dict = {}
new = set(column[0] for column in new_list)
...
...
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