Skip Menu |

This queue is for tickets about the Rose-DB CPAN distribution.

Report information
The Basics
Id: 45836
Status: resolved
Priority: 0/
Queue: Rose-DB

People
Owner: Nobody in particular
Requestors: ian [...] bartonia.net
Cc:
AdminCc:

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



Subject: Rose::DB::SQLite not properly stripping quotes from primary key columns
Date: Thu, 7 May 2009 21:13:56 -0500
To: bug-Rose-DB [...] rt.cpan.org
From: Ian Barton <ian [...] bartonia.net>
Distribution: Rose-DB-0.751 Module: Rose::DB::SQLite ($VERSION = 0.745) Perl version: 5.10.0 Operating system: Mac OS X 10.5.6 (darwin 9.6.0 i386) Summary: When attempting to use the auto-initialization features to interrogate a database created via Ruby on Rails, the Rose::DB::Object::Loader module croaks with the following message: Primary key column '"id"' is not in the column list for <module name> at /usr/local/lib/perl5/site_perl/5.10.0/Rose/DB/Object/Loader.pm line 941 Some investigation revealed that the problem actually arose from the way that Rose::DB::SQLite handles the table metadata. In particular, if quotation marks are used in the SQL supplied to create the database (as is done by the Ruby on Rails migration tool), Rose::DB::SQLite is not currently stripping out the quotes when populating the primary- keys array, and thus it fails when trying to lookup those key names in the object-level hash. Steps to reproduce: Save the attached files Execute the shell script to create a test database (with tables created with both quoted and unquoted identifiers) and attempt to emit appropriate modules via auto-initialization methods Confirm that the modules are not created and instead the error message is printed Suggested solution: Change line 399 of Rose/DB/SQLite.pm from push(@pk_columns, $col_name); to push(@pk_columns, _unquote_name($col_name)); which 'cleans' the primary-key column names and fixes the bug.
Distribution: Rose-DB-0.751
Module: Rose::DB::SQLite ($VERSION = 0.745)
Perl version: 5.10.0
Operating system: Mac OS X 10.5.6 (darwin 9.6.0 i386)

Summary:

When attempting to use the auto-initialization features to interrogate a database created via Ruby on Rails, the Rose::DB::Object::Loader module croaks with the following message:

Show quoted text
Primary key column '"id"' is not in the column list for <module name> at /usr/local/lib/perl5/site_perl/5.10.0/Rose/DB/Object/Loader.pm line 941
Show quoted text

Some investigation revealed that the problem actually arose from the way that Rose::DB::SQLite handles the table metadata. In particular, if quotation marks are used in the SQL supplied to create the database (as is done by the Ruby on Rails migration tool), Rose::DB::SQLite is not currently stripping out the quotes when populating the primary-keys array, and thus it fails when trying to lookup those key names in the object-level hash.

Steps to reproduce:

  1. Save the attached files
  2. Execute the shell script to create a test database (with tables created with both quoted and unquoted identifiers) and attempt to emit appropriate modules via auto-initialization methods
  3. Confirm that the modules are not created and instead the error message is printed
Download bug_report.sh
application/octet-stream 105b

Message body not shown because it is not plain text.

Download bug_report.sql
application/octet-stream 183b

Message body not shown because it is not plain text.

Message body is not shown because sender requested not to inline it.


Suggested solution:

Change line 399 of Rose/DB/SQLite.pm from

Show quoted text
       push(@pk_columns, $col_name);
to

Show quoted text
       push(@pk_columns, _unquote_name($col_name));
Show quoted text

which 'cleans' the primary-key column names and fixes the bug.




This is fixed in Rose::DB 0.752, just uploaded to CPAN.