Skip Menu |

This queue is for tickets about the Tangram CPAN distribution.

Report information
The Basics
Id: 2637
Status: resolved
Worked: 35 min
Priority: 0/
Queue: Tangram

People
Owner: SAMV [...] cpan.org
Requestors: giorgos [...] perlfect.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: but he is not dead yet...
From: giorgos zervas <giorgos [...] perlfect.com>
To: bug-Tangram [...] rt.cpan.org
Date: 23 May 2003 10:41:38 +0000
Here is a bug. A schema like that works fine... fields => { string => [ qw( firstName name ) ], int => [ qw( age ) ], ref => { partner => { null => 1 } }, array => { children => 'NaturalPerson' }, }, However something like: fields => { string => [ qw( firstName name ) ], int => [ qw( age ) ], ref => { partner => { null => 1 } }, array => { children => 'Natural::Person' }, # NOTICE THE "::" HERE }, produces SQL problems as it tries to create a column with "::" in its name and mysql doesn't like that. The way around that, that I have found, is: fields => { string => [ qw( firstName name ) ], int => [ qw( age ) ], ref => { partner => { null => 1 } }, array => { children => { class => 'Natural::Person'} }, }, i.e. using the long form of the specification. My normalize function looks like: sub normalize { my ($name, $type) = @_; $name =~ s/\:\://g; return $name; } It seems that altough the normalize function is applied to table names it is not applied to column names. I hope my explanation is clear... I am using 2.04. Best regards, Giorgos
Well, I can't take him like that! It's against regulations! Are you sure your bug does not apply to the `iarray' type? With `array', you get a link table, and the normalize function is properly applied to that. However, with the `iarray' type, I consistently get columns with "::" in them; I have tried both of the schema variations that you list with the same result. With `iarray', you can control the mapping (unfortunately, only on a field by field basis) via the `coll' and `slot' properties of the long form of the schema. I have attached the script that I used to demonstrate this to myself, using Tangram 2.05pre1. [giorgos@perlfect.com - Fri May 23 03:42:09 2003]: Show quoted text
> Here is a bug. > > A schema like that works fine... > > fields => > { > string => [ qw( firstName name ) ], > int => [ qw( age ) ], > ref => { partner => { null => 1 } }, > array => { children => 'NaturalPerson' }, > }, > > However something like: > > fields => > { > string => [ qw( firstName name ) ], > int => [ qw( age ) ], > ref => { partner => { null => 1 } }, > array => { children => 'Natural::Person' }, # NOTICE > THE "::" HERE > }, > > > produces SQL problems as it tries to create a column with "::" in its > name and mysql doesn't like that. > > > The way around that, that I have found, is: > > fields => > { > string => [ qw( firstName name ) ], > int => [ qw( age ) ], > ref => { partner => { null => 1 } }, > array => { children => { class => 'Natural::Person'} > }, > }, > > i.e. using the long form of the specification. > > My normalize function looks like: > > sub normalize { > my ($name, $type) = @_; > $name =~ s/\:\://g; > return $name; > } > > It seems that altough the normalize function is applied to table names > it is not applied to column names. > > I hope my explanation is clear... I am using 2.04. > > Best regards, > Giorgos > >
#!/usr/bin/perl -w use strict; use Test::More tests => 2; use Tangram::Relational; use Tangram::Schema; use Tangram::Scalar; use Tangram::Ref; use Tangram::IntrArray; my $schema = Tangram::Schema->new ( classes => [ NaturalPerson => { fields => { string => [ qw( firstName name ) ], int => [ qw( age ) ], ref => { partner => { null => 1 } }, iarray => { children => 'NaturalPerson' }, }, }, Natural::Person => { fields => { string => [ qw( firstName name ) ], int => [ qw( age ) ], ref => { partner => { null => 1 } }, iarray => { children => 'Natural::Person' }, }, }, UnNatural::Person => { fields => { string => [ qw( firstName name ) ], int => [ qw( age ) ], ref => { partner => { null => 1 } }, iarray => { children => { class => 'UnNatural::Person', } }, }, }, Natural::Bloke => { fields => { string => [ qw( firstName name ) ], int => [ qw( age ) ], ref => { partner => { null => 1 } }, iarray => { children => { class => 'Natural::Bloke', coll => "foo", slot => "bar", } }, }, }, ], normalize => sub { my ($name, $type) = @_; $name =~ s/\:\:/_/g; return $name; }, ); Tangram::Relational->deploy($schema);
[giorgos@perlfect.com - Mon May 26 09:25:10 2003]: Show quoted text
> I meant iarray instead of array. I know the work around with the full > specification, but before I discovered it was something that troubled me > for a while. Therefore I thought it would be nice to fix the bug before > it confuses more people!
Absolutely. I have fixed this in CVS; Class names are now normalised before having the "_slot", etc added to them. This will be included in the 2.05pre2 release.
Fixed in 2.06, closing this old ticket