Bug 674433 - rhubarb should raise a user-friendly error message when creating a table with no declared columns
Summary: rhubarb should raise a user-friendly error message when creating a table with...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: ruby-rhubarb
Version: 1.3
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: 2.0
: ---
Assignee: Will Benton
QA Contact: Tomas Rusnak
URL:
Whiteboard:
Depends On:
Blocks: 693778
TreeView+ depends on / blocked
 
Reported: 2011-02-01 21:08 UTC by Robert Rati
Modified: 2011-06-23 15:42 UTC (History)
4 users (show)

Fixed In Version: rhubarb-0.3.0-1
Doc Type: Bug Fix
Doc Text:
C: The rhubarb library previously did not allow users to create persisting classes with no declared columns. C: Although creating persisting classes that have no persisting data members is an unlikely use case, users who attempted to do so would be met with a confusing error message because certain internal data structures were only created when a column was declared. F: The rhubarb library now ensures that necessary initialization steps take place even if no columns are declared. R: It is now possible to declare persisting classes with no persisting columns. Summary: It is now possible to use the rhubarb library to create persisting classes with no declared columns.
Clone Of:
Environment:
Last Closed: 2011-06-23 15:42:28 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2011:0889 0 normal SHIPPED_LIVE Red Hat Enterprise MRG Grid 2.0 Release 2011-06-23 15:35:53 UTC

Description Robert Rati 2011-02-01 21:08:35 UTC
Description of problem:
Calling rhubarb_obj.create_tables if the obj does not have any declared tables results in a confusing error message.  Even better would be if rhubarb could handle the issue gracefully and allow create_tables be called when no columns have been declared.

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Will Benton 2011-02-14 22:33:31 UTC
Fixed in master, packaged soon.

Comment 2 Will Benton 2011-02-14 22:33:31 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
C:  The rhubarb library previously did not allow users to create persisting classes with no declared columns.
C:  Although creating persisting classes that have no persisting data members is an unlikely use case, users who attempted to do so would be met with a confusing error message because certain internal data structures were only created when a column was declared.
F:  The rhubarb library now ensures that necessary initialization steps take place even if no columns are declared.
R:  It is now possible to declare persisting classes with no persisting columns.

Summary:  It is now possible to use the rhubarb library to create persisting classes with no declared columns.

Comment 3 Martin Kudlej 2011-03-07 13:19:53 UTC
What are the exact steps to reproduce this issue in console, please?

Comment 4 Will Benton 2011-03-09 06:50:45 UTC
Here's part of an irb transcript with the old behavior:

irb(main):016:0> require 'rhubarb/rhubarb'
=> true
irb(main):017:0> class Blah
irb(main):018:1>   include ::Rhubarb::Persisting
irb(main):019:1> end
=> Blah
irb(main):020:0> ::Rhubarb::Persistence::open(":memory:")
=> #<SQLite3::Database:0x7fb2586db9f8 @translator=nil, @statement_factory=SQLite3::Statement, @type_translation=true, @results_as_hash=true, @driver=#<SQLite3::Driver::Native::Driver:0x7fb2586db8b8 @callback_data={}, @trace={}, @busy_handler={}, @authorizer={}>, @transaction_active=false, @closed=false, @handle=#<SWIG::TYPE_p_sqlite3:0x7fb2586ae160>>
irb(main):021:0> Blah.create_table
NameError: undefined local variable or method `columns' for Blah:Class
	from /usr/lib/ruby/site_ruby/1.8/rhubarb/classmixins.rb:254:in `table_decl'
	from /usr/lib/ruby/site_ruby/1.8/rhubarb/classmixins.rb:261:in `create_table'
	from (irb):21
	from /usr/lib/ruby/1.8/set.rb:272

You can just paste the following in to irb to reproduce the issue:

---snip---
require 'rhubarb/rhubarb'
class Blah; include ::Rhubarb::Persisting; end
::Rhubarb::Persistence::open(":memory:")
Blah.create_table
---snip---

Comment 6 Tomas Rusnak 2011-05-04 13:11:24 UTC
Reproduced on x86_64/RHEL5 with ruby-rhubarb-0.2.7

# irb
irb(main):001:0> require 'rhubarb/rhubarb'
=> true
irb(main):002:0> class Blah; include ::Rhubarb::Persisting; end
=> Blah
irb(main):003:0> ::Rhubarb::Persistence::open(":memory:")
=> #<SQLite3::Database:0x2b516184d950 @driver=#<SQLite3::Driver::Native::Driver:0x2b516184d810 @trace={}, @busy_handler={}, @authorizer={}, @callback_data={}>, @transaction_active=false, @closed=false, @handle=#<SWIG::TYPE_p_sqlite3:0x2b516183e0e0>, @translator=nil, @statement_factory=SQLite3::Statement, @type_translation=true, @results_as_hash=true>
irb(main):004:0> Blah.create_table
NameError: undefined local variable or method `columns' for Blah:Class
	from /usr/lib/ruby/site_ruby/1.8/rhubarb/classmixins.rb:254:in `table_decl'
	from /usr/lib/ruby/site_ruby/1.8/rhubarb/classmixins.rb:261:in `create_table'
	from (irb):4

Comment 7 Tomas Rusnak 2011-05-04 13:13:38 UTC
Retested over all supported platforms x86,x86_64/RHEL5,RHEL6 with ruby-rhubarb-0.3.0-2:

# irb
irb(main):001:0> require 'rhubarb/rhubarb'
=> true
irb(main):002:0> class Blah; include ::Rhubarb::Persisting; end
=> Blah
irb(main):003:0> ::Rhubarb::Persistence::open(":memory:")
=> #<SQLite3::Database:0xb7d29cc4 @driver=#<SQLite3::Driver::Native::Driver:0xb7d29c24 @callback_data={}, @trace={}, @busy_handler={}, @authorizer={}>, @transaction_active=false, @closed=false, @handle=#<SWIG::TYPE_p_sqlite3:0xb7d220b4>, @translator=nil, @statement_factory=SQLite3::Statement, @type_translation=true, @results_as_hash=true>
irb(main):004:0> Blah.create_table
=> []
irb(main):005:0>

>>> VERIFIED

Comment 8 errata-xmlrpc 2011-06-23 15:42:28 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2011-0889.html


Note You need to log in before you can comment on or make changes to this bug.