Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ensembl-hive
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
7
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-hive
Commits
5b379206
Commit
5b379206
authored
11 years ago
by
Leo Gordon
Browse files
Options
Downloads
Patches
Plain Diff
implemented input_column_mapping mechanism
parent
0411ab95
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/Bio/EnsEMBL/Hive/DBSQL/BaseAdaptor.pm
+23
-9
23 additions, 9 deletions
modules/Bio/EnsEMBL/Hive/DBSQL/BaseAdaptor.pm
with
23 additions
and
9 deletions
modules/Bio/EnsEMBL/Hive/DBSQL/BaseAdaptor.pm
+
23
−
9
View file @
5b379206
...
...
@@ -56,6 +56,15 @@ sub default_overflow_limit {
return
{
# 'overflow_column1_name' => column1_size,
# 'overflow_column2_name' => column2_size,
# ...
};
}
sub
default_input_column_mapping
{
return
{
# 'original_column1' => "original_column1*10 AS c1_times_ten",
# 'original_column2' => "original_column2+1 AS c2_plus_one",
# ...
};
}
...
...
@@ -70,6 +79,16 @@ sub overflow_limit {
}
sub
input_column_mapping
{
my
$self
=
shift
@_
;
if
(
@
_
)
{
# setter
$self
->
{
_input_column_mapping
}
=
shift
@_
;
}
return
$self
->
{
_input_column_mapping
}
||
$self
->
default_input_column_mapping
();
}
sub
table_name
{
my
$self
=
shift
@_
;
...
...
@@ -203,19 +222,14 @@ sub count_all {
sub
fetch_all
{
my
(
$self
,
$constraint
,
$one_per_key
,
$key_list
,
$value_column
)
=
@_
;
my
$table_name
=
$self
->
table_name
();
my
$table_name
=
$self
->
table_name
();
my
$input_column_mapping
=
$self
->
input_column_mapping
();
my
$sql
=
'
SELECT
'
.
join
('
,
',
keys
%
{
$self
->
column_set
()})
.
"
FROM
$table_name
";
my
$sql
=
'
SELECT
'
.
join
('
,
',
map
{
$input_column_mapping
->
{
$_
}
//
"
$table_name
.
$_
"
}
keys
%
{
$self
->
column_set
()})
.
"
FROM
$table_name
";
if
(
$constraint
)
{
# in case $constraint contains any kind of JOIN (regular, LEFT, RIGHT, etc) do not put WHERE in front:
if
(
$constraint
=~
/\bJOIN\b/i
)
{
$sql
=
'
SELECT
'
.
join
('
,
',
map
{
"
$table_name
.
$_
"
}
keys
%
{
$self
->
column_set
()})
.
"
FROM
$table_name
$constraint
";
}
elsif
(
$constraint
=~
/^LIMIT|ORDER|GROUP/
)
{
$sql
.=
'
'
.
$constraint
;
}
else
{
$sql
.=
'
WHERE
'
.
$constraint
;
}
$sql
.=
((
$constraint
=~
/\bJOIN\b/i
or
$constraint
=~
/^LIMIT|ORDER|GROUP/
)
?
'
'
:
'
WHERE
')
.
$constraint
;
}
# warn "SQL: $sql\n";
...
...
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