J
Justin C
I am writing a module which interacts with a database. It is only
able to perform certain types of query, and return data in certain
formats (I'm not opening up the whole of DBIx for users of the
module - if they want to do more then my module isn't for them).
So the user creates a new query using my module:
my $q = Module:B::Query->new({
type => 'select',
table => 'products',
cols_wanted => [qw/foo bar baz/],
criteria => [
{ column => 'id', value => 7, operator => '>' },
{ column => 'description', value => 'lorem', operator => '=' },
],
return => 'aoa' # array of arrays
});
I'm looking for a way to describe all the permutations for the
different queries my module can handle, in a way that can be used
to test that I have all the data I need to run the query.
I started with this:
my %supported = {
select => {
table => 'SCALAR',
cols_wanted => 'ARRAY',
criteria => [{
column => 'SCALAR',
value => 'SCALAR',
operator => 'SCALAR'
}],
}
update => {
}
insert => {
}
}
But as you can see it very soon breaks down. There's no way in my
scheme for 'criteria' to be specified as an array of hashes.
I'm sure this problem must have come up before and a solution
exist. Maybe I'm just thinking about this the wrong way, and
someone could steer my thinking in the right way?
Thank you for your suggestions.
Justin.
able to perform certain types of query, and return data in certain
formats (I'm not opening up the whole of DBIx for users of the
module - if they want to do more then my module isn't for them).
So the user creates a new query using my module:
my $q = Module:B::Query->new({
type => 'select',
table => 'products',
cols_wanted => [qw/foo bar baz/],
criteria => [
{ column => 'id', value => 7, operator => '>' },
{ column => 'description', value => 'lorem', operator => '=' },
],
return => 'aoa' # array of arrays
});
I'm looking for a way to describe all the permutations for the
different queries my module can handle, in a way that can be used
to test that I have all the data I need to run the query.
I started with this:
my %supported = {
select => {
table => 'SCALAR',
cols_wanted => 'ARRAY',
criteria => [{
column => 'SCALAR',
value => 'SCALAR',
operator => 'SCALAR'
}],
}
update => {
}
insert => {
}
}
But as you can see it very soon breaks down. There's no way in my
scheme for 'criteria' to be specified as an array of hashes.
I'm sure this problem must have come up before and a solution
exist. Maybe I'm just thinking about this the wrong way, and
someone could steer my thinking in the right way?
Thank you for your suggestions.
Justin.