Mercurial > pub > Impl
diff Lib/Schema/DataSource/TypeMapping.pm @ 49:16ada169ca75
migrating to the Eclipse IDE
author | wizard@linux-odin.local |
---|---|
date | Fri, 26 Feb 2010 10:49:21 +0300 |
parents | 03e58a454b20 |
children |
line wrap: on
line diff
--- a/Lib/Schema/DataSource/TypeMapping.pm Fri Feb 26 01:43:42 2010 +0300 +++ b/Lib/Schema/DataSource/TypeMapping.pm Fri Feb 26 10:49:21 2010 +0300 @@ -1,46 +1,46 @@ -use strict; -package Schema::DataSource::TypeMapping; -use Common; -our @ISA = qw(Object); - -BEGIN { - DeclareProperty Mappings => ACCESS_NONE; - DeclareProperty DBIdentifierType => ACCESS_READ; - DeclareProperty DBValueType => ACCESS_READ; -} - -sub MapType { - my ($this,$Type) = @_; - - if (my $mapped = $this->{$Mappings}->{$Type->Name->Canonical}) { - return $mapped; - } elsif ($Type->Attributes and $Type->GetAttribute('ValueType')) { - return $this->{$DBValueType}; - } else { - return $this->{$DBIdentifierType}; - } -} - -package Schema::DataSource::TypeMapping::Std; -use Schema::DB::Type; -our @ISA = qw(Schema::DataSource::TypeMapping); - -sub CTOR { - my ($this) = @_; - $this->SUPER::CTOR( - Mappings => { - Identifier => new Schema::DB::Type(Name => 'Integer'), - String => new Schema::DB::Type(Name => 'varchar', MaxLength => 255), - Integer => new Schema::DB::Type(Name => 'Integer'), - Float => new Schema::DB::Type(Name => 'Real'), - DateTime => new Schema::DB::Type(Name => 'DateTime'), - Bool => new Schema::DB::Type(Name => 'Tinyint'), - Blob => new Schema::DB::Type(Name => 'Blob'), - Text => new Schema::DB::Type(Name => 'Text') - }, - DBIdentifierType => new Schema::DB::Type(Name => 'Integer'), - DBValueType => new Schema::DB::Type(Name => 'varchar', MaxLength => 255) - ); -} - -1; +use strict; +package Schema::DataSource::TypeMapping; +use Common; +our @ISA = qw(Object); + +BEGIN { + DeclareProperty Mappings => ACCESS_NONE; + DeclareProperty DBIdentifierType => ACCESS_READ; + DeclareProperty DBValueType => ACCESS_READ; +} + +sub MapType { + my ($this,$Type) = @_; + + if (my $mapped = $this->{$Mappings}->{$Type->Name->Canonical}) { + return $mapped; + } elsif ($Type->Attributes and $Type->GetAttribute('ValueType')) { + return $this->{$DBValueType}; + } else { + return $this->{$DBIdentifierType}; + } +} + +package Schema::DataSource::TypeMapping::Std; +use Schema::DB::Type; +our @ISA = qw(Schema::DataSource::TypeMapping); + +sub CTOR { + my ($this) = @_; + $this->SUPER::CTOR( + Mappings => { + Identifier => new Schema::DB::Type(Name => 'Integer'), + String => new Schema::DB::Type(Name => 'varchar', MaxLength => 255), + Integer => new Schema::DB::Type(Name => 'Integer'), + Float => new Schema::DB::Type(Name => 'Real'), + DateTime => new Schema::DB::Type(Name => 'DateTime'), + Bool => new Schema::DB::Type(Name => 'Tinyint'), + Blob => new Schema::DB::Type(Name => 'Blob'), + Text => new Schema::DB::Type(Name => 'Text') + }, + DBIdentifierType => new Schema::DB::Type(Name => 'Integer'), + DBValueType => new Schema::DB::Type(Name => 'varchar', MaxLength => 255) + ); +} + +1;