Bio-DB-Big

 view release on metacpan or  search on metacpan

t/30autosql.t  view on Meta::CPAN

=head1 LICENSE

Copyright [2015-2017] EMBL-European Bioinformatics Institute

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

=cut

use strict;
use warnings;

use Test::More;
use Test::Differences;
use Test::Exception;

use Bio::DB::Big::AutoSQL;

my $raw_autosql = qq{table addressBook
"A simple address book"
    (
    uint id primary auto; "Autoincrementing primary key for this record."
    string name unique;  "Name - first or last or both, we don't care, except it must be unique"
    lstring address;  "Street address"
    string city index[12];  "City - indexing just first 12 character"
    uint zipCode index;  "A zip code is always positive, so can be unsigned"
    char[2] state index;  "Just store the abbreviation for the state"
    enum(one, two) testenum; "Checking enums"
    set(blib,blob) testset; "Checking sets"
    int faceCount; "Numbers of faces"
    object face[faceCount] faces; "List of faces"
    simple point[faceCount] points; "Array of points"
    lstring field12; "Undocumented field"
    lstring random; "Undocumented field"
    )};
my $alternative_name_lookup = {postcode => 'zipCode'};
my $as = Bio::DB::Big::AutoSQL->new($raw_autosql, $alternative_name_lookup);

my $as_obj = 'Bio::DB::Big::AutoSQLField';
my $expected_structure = bless({
  raw => $raw_autosql,
  type => 'table',
  name => 'addressBook',
  comment => 'A simple address book',
  alternative_name_lookup => $alternative_name_lookup,
  fields => [
    bless(
    { type => 'uint', name => 'id', comment => 'Autoincrementing primary key for this record.', position => 1,
      field_size => undef, field_values => [], declare_size => undef, index_type => 'primary',
      index_size => undef, auto => 'auto', declare_name => undef,
    }, $as_obj),
    bless(
    { type => 'string', name => 'name', comment => q{Name - first or last or both, we don't care, except it must be unique}, position => 2,
      field_size => undef, field_values => [], declare_size => undef, index_type => 'unique',
      index_size => undef, auto => undef, declare_name => undef,
    }, $as_obj),
    bless(
    { type => 'lstring', name => 'address', comment => 'Street address', position => 3,
      field_size => undef, field_values => [], declare_size => undef, index_type => undef,
      index_size => undef, auto => undef, declare_name => undef,
    }, $as_obj),
    bless(
    { type => 'string', name => 'city', comment => 'City - indexing just first 12 character', position => 4,
      field_size => undef, field_values => [], declare_size => undef, index_type => 'index',
      index_size => "12", auto => undef, declare_name => undef,
    }, $as_obj),
    bless(
    { type => 'uint', name => 'zipCode', comment => 'A zip code is always positive, so can be unsigned', position => 5,
      field_size => undef, field_values => [], declare_size => undef, index_type => 'index',
      index_size => undef, auto => undef, declare_name => undef,
    }, $as_obj),
    bless(
    { type => 'char', name => 'state', comment => 'Just store the abbreviation for the state', position => 6,
      field_size => "2", field_values => [], declare_size => undef, index_type => 'index',



( run in 0.635 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )