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
Show quoted text
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.
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
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
Message body not shown because it is not plain text.
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
push(@pk_columns, $col_name);
Show quoted text
push(@pk_columns, _unquote_name($col_name));