You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Kee Hinckley <na...@somewhere.com> on 2001/11/15 03:14:03 UTC

SQLx::Recordset and DBD::CSV -- odd delete behavior

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm going to report this as a "for what it's worth" report.  I've 
spent many hours tracking it down, and I finally found a reasonable 
work around, but I haven't been able to create a simple reproducible 
instance of the problem and it may not be worth doing so.  I do have 
one solid question at the bottom though.

I have a database with a "uid" field which consists of simple 
numbers.  This is the primary key, and I use Setup to say so.

         $this->{_set} = DBIx::Recordset->Setup({
                         '!DataSource' => $this->{_db},
                         '!Table' => 'publications',
                         '!PrimKey' => 'uid',
                         });

Of course CSV files aren't typed, so Recordset doesn't know it's an integer.

If I call $$set->Delete({uid => 85}), Recordset will construct an SQL 
command of:
	DELETE WHERE uid = ?
and pass 85 as the value

If I put debug statements in SQL::Statement (the C code) I find that 
the column is a string "85" and the parameter is.... sometimes an 
integer (works) and sometimes a real (doesn't).

I have no idea whatsoever why it's a real. I gave up debugging (it 
gets real messy around the interface the C code) and trying to figure 
out whether it was DBIx::Recordset, DBI::CSV, DBI::File, 
SQL::Statement, SQL::Eval or Statement.xs that was causing the 
problem.  It won't happen in a simple test case, some combination of 
queries sets it up.  I have code in which it always happens, but it's 
complicated.  Whoever it was,  a string comparison of "85" and 
"85.00000" doesn't work real well.

Fortunately, this works:

     my $cnt = $$set->Delete({'#uid' => 85});

Is there a way of setting that up at Setup time instead of every time 
I do a query?
- -- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
nazgul@somewhere.com (or ...!alice!nazgul for time travelers :-)

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Security 7.0.3

iQA/AwUBO/Mk8SZsPfdw+r2CEQLJcQCdGpu4fuG/S+yF49LKm9G4dAHRGMkAnRaH
fsoK+kpTz6Tk4hfceU787jzJ
=FtS2
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: SQLx::Recordset and DBD::CSV -- odd delete behavior

Posted by Gerald Richter <ri...@ecos.de>.
>
> >in function QueryMetaData, around line 241. It would be necessary to set
the
> >hash %Numeric accordingly. If it's important for you, maybe you can make
a
> >patch. I am happy to include it
>
> I'll take a look at it.  For now I'm happy with my work-around, and I
> tend to use CSV for prototyping, switching to MySQL once the
> interface has stablized or I reach the point of needing joins.

As long as you are happy with your workaround, I think there is no urgent
reason to add this functionality to DBIx::Recordset

Gerald

-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: SQLx::Recordset and DBD::CSV -- odd delete behavior

Posted by Kee Hinckley <na...@somewhere.com>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

At 9:41 PM +0100 11/15/01, Gerald Richter wrote:
>  > I have no idea whatsoever why it's a real. I gave up debugging (it
>>  gets real messy around the interface the C code)
>
>I can imagine this...

At this point I suspect some questionable looking code in DBD::CVS 
where it's converting between an internal type and an external type 
value by adding 6 to everything.

>unfortunately not. The information is taken from the driver, in Database.pm

DBD::File (which DBD::CSV inherits from) actually has a way to set 
the information, but I can't figure out how to get my hands on that 
object.

>in function QueryMetaData, around line 241. It would be necessary to set the
>hash %Numeric accordingly. If it's important for you, maybe you can make a
>patch. I am happy to include it

I'll take a look at it.  For now I'm happy with my work-around, and I 
tend to use CSV for prototyping, switching to MySQL once the 
interface has stablized or I reach the point of needing joins.
- -- 

Kee Hinckley - Somewhere.Com, LLC
http://consulting.somewhere.com/
nazgul@somewhere.com (or ...!alice!nazgul for time travelers :-)

I'm not sure which upsets me more: that people are so unwilling to accept
responsibility for their own actions, or that they are so eager to regulate
everyone else's.

-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Security 7.0.3

iQA/AwUBO/R6myZsPfdw+r2CEQJW5ACggaLtImu78uM6ob+o4T6Bypc7xiUAoOgQ
f9ls0DysrZ86uri8jgPXUVPm
=6bpu
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: SQLx::Recordset and DBD::CSV -- odd delete behavior

Posted by Gerald Richter <ri...@ecos.de>.
>
> If I put debug statements in SQL::Statement (the C code) I find that
> the column is a string "85"

DBIx::Recordset passes it always as string to DBI

>and the parameter is.... sometimes an
> integer (works) and sometimes a real (doesn't).
>

strange...

> I have no idea whatsoever why it's a real. I gave up debugging (it
> gets real messy around the interface the C code)

I can imagine this...

>
> Fortunately, this works:
>
>      my $cnt = $$set->Delete({'#uid' => 85});

This let DBIx::Recordset convert it to an integer before it passes it down
to DBI
>
> Is there a way of setting that up at Setup time instead of every time
> I do a query?

unfortunately not. The information is taken from the driver, in Database.pm
in function QueryMetaData, around line 241. It would be necessary to set the
hash %Numeric accordingly. If it's important for you, maybe you can make a
patch. I am happy to include it

Gerald



-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925131
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org