Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
ensembl
Commits
19c145aa
Commit
19c145aa
authored
14 years ago
by
Nathan Johnson
Browse files
Options
Downloads
Patches
Plain Diff
added a little voodoo to handle the end of table definitions better
parent
41b25751
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc-scripts/sql2html.pl
+32
-12
32 additions, 12 deletions
misc-scripts/sql2html.pl
with
32 additions
and
12 deletions
misc-scripts/sql2html.pl
+
32
−
12
View file @
19c145aa
...
...
@@ -160,7 +160,7 @@ my $count_sql_col = 0;
my
$tag_content
=
'';
my
$tag
=
'';
my
$display
=
'
Show
';
my
$parenth_count
=
0
;
#############
## Parser ##
...
...
@@ -177,7 +177,8 @@ while (<SQLFILE>) {
if
(
$_
=~
/^\s*create\s+table\s+(if\s+not\s+exists\s+)?(\S+)/i
)
{
# start to parse the content of the table
my
$sql_t_name
=
remove_char
(
$
2
);
if
(
$sql_t_name
eq
$table
)
{
$in_table
=
1
;
$in_table
=
1
;
$parenth_count
++
;
}
else
{
print
STDERR
"
The documentation of the table
$sql_t_name
has not be found!
\n
";
...
...
@@ -236,6 +237,33 @@ while (<SQLFILE>) {
## Parsing of the SQL table to fetch the columns types ##
elsif
(
$in_table
==
1
)
{
#END OF TABLE DEFINITION
#Can't do this easily with a simply regex as there are varying valid formats
#The end of the table definition is actually defined by 2nd enclosing bracket
#Regex counting VOODOO!
#This basically puts the regex in a list context
#before inc/dec'ing with it in a scalar context.
$parenth_count
+=
()
=
$doc
=~
/\(/gi
;
$parenth_count
-=
()
=
$doc
=~
/\)/gi
;
if
(
$parenth_count
==
0
)
{
# End of the sql table definition
if
(
scalar
@
{
$documentation
->
{
$header
}{'
tables
'}{
$table
}{
column
}}
>
$count_sql_col
)
{
#use Data::Dumper;
#warn "col count $count_sql_col";
#warn Data::Dumper::Dumper(\$documentation);
print
STDERR
"
Description of a non existant column in the table
$table
!
\n
";
}
$in_table
=
0
;
$count_sql_col
=
0
;
$table
=
'';
$parenth_count
=
0
;
}
else
{
## INDEXES ##
if
(
$doc
=~
/^\s*(primary\skey)\s*\((.+)\)/i
or
$doc
=~
/^\s*(unique)\s*\((.+)\)/i
){
# Primary or unique
my
$icol
=
remove_char
(
$
2
);
...
...
@@ -259,17 +287,8 @@ while (<SQLFILE>) {
my
$col_def
=
'';
if
(
$doc
=~
/\).*;/
)
{
# End of the sql table definition
if
(
scalar
@
{
$documentation
->
{
$header
}{'
tables
'}{
$table
}{
column
}}
>
$count_sql_col
)
{
print
STDERR
"
Description of a non existant column in the table
$table
!
\n
";
}
$in_table
=
0
;
$count_sql_col
=
0
;
$table
=
'';
}
# All the type is contained in the same line (type followed by parenthesis)
els
if
(
$doc
=~
/^\W*(\w+)\W+(\w+\s?\(.*\))/
){
if
(
$doc
=~
/^\W*(\w+)\W+(\w+\s?\(.*\))/
){
$col_name
=
remove_char
(
$
1
);
$col_type
=
$
2
;
if
(
$doc
=~
/default\s*([^,\s]+)\s*.*(,|#).*/i
)
{
$col_def
=
$
1
;
}
# Default value
...
...
@@ -306,6 +325,7 @@ while (<SQLFILE>) {
if
(
$doc
=~
/default\s*([^,\s]+)\s*.*(,|#).*/i
)
{
$col_def
=
$
1
;}
# Default value
add_column_type_and_default_value
(
$col_name
,
$col_type
,
$col_def
);
}
}
}
}
close
(
SQLFILE
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment