diff Lib/IMPL/ORM/Object.pm @ 44:32d2350fccf9

ORM *Minor fixes *Working tarnsform to sql *Fixes to the sql traits
author Sergey
date Mon, 11 Jan 2010 01:42:00 +0300
parents d660fb38b7cc
children 16ada169ca75
line wrap: on
line diff
--- a/Lib/IMPL/ORM/Object.pm	Thu Jan 07 15:41:49 2010 +0300
+++ b/Lib/IMPL/ORM/Object.pm	Mon Jan 11 01:42:00 2010 +0300
@@ -15,7 +15,11 @@
 
 BEGIN {
     private _direct property _entities => prop_all;
-    public property objectType => prop_all;
+    public property objectType => prop_all, {type => 'String'};
+    
+    sub _PropertyImplementor {
+        'IMPL::ORM::PropertyImplementor'
+    }
 }
 
 my %schemaCache;
@@ -42,12 +46,8 @@
     return $this->{$_entities}{$class} ? $this->{$_entities}{$class}->Get($prop,$value) : undef;
 }
 
-sub _PropertyImplementor {
-    'IMPL::ORM::PropertyImplementor'
-}
-
 sub entityName {
-    (my $self = ref $_[0] || $_[0]) =~ s/::/_/g;
+    (my $self = ref $_[0] || $_[0]) =~ s/^.*?(\w+)$/$1/;
     return $self;
 }
 
@@ -70,9 +70,9 @@
             # отношение 1 ко многим
             my $type = $dataSchema->resolveType($ormProp->Type) or die new IMPL::InvalidOperationException("Failed to resolve a reference type due building schema for a class", $ormProp->Class, $ormProp->Name);
             $schema->appendChild( new IMPL::ORM::Schema::Relation::HasMany($ormProp->Name, $type->entityName) );
-        } elsif (my $type = $dataSchema->isValueType($ormProp->Type,'IMPL::ORM::Object')) {
+        } elsif (my $type = $dataSchema->isValueType($ormProp->Type)) {
             # поле
-            $schema->appendChild( new IMPL::ORM::Schema::Field($ormProp->Name,$type->name) );
+            $schema->appendChild( new IMPL::ORM::Schema::Field($ormProp->Name,$ormProp->Type) );
         } elsif (my $entity = $dataSchema->resolveType($ormProp->Type)) {
             # отношение ссылка
             $schema->appendChild( new IMPL::ORM::Schema::Relation::HasOne($ormProp->Name,$entity->entityName));