Bug 674432 - rhubarb should work with classes named after sql reserved words
Summary: rhubarb should work with classes named after sql reserved words
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:06 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 named after SQL reserved words. C: This required users to specify an alternate table name with the declare_table_name option. F: Rhubarb now quotes table names in all generated SQL code. R: It is now possible to declare persisting classes named after SQL reserved words, like "Group" or "Order". Summary: It is now possible to use the rhubarb library to create persisting classes that share names with SQL reserved words.
Clone Of:
Environment:
Last Closed: 2011-06-23 15:42:25 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:06:09 UTC
Description of problem:
When creating a class that uses rhubarb, if you create a class name that is the same as an SQL reserved word you get an error similar to:

/usr/lib/ruby/site_ruby/1.8/sqlite3/errors.rb:62:in `check': near "group": syntax error (SQLite3::SQLException)

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 23:17:07 UTC
Fixed in master.

Comment 2 Will Benton 2011-02-14 23:17:07 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 named after SQL reserved words.
C:  This required users to specify an alternate table name with the declare_table_name option.
F:  Rhubarb now quotes table names in all generated SQL code.
R:  It is now possible to declare persisting classes named after SQL reserved words, like "Group" or "Order".

Summary:  It is now possible to use the rhubarb library to create persisting classes that share names with SQL reserved words.

Comment 4 Tomas Rusnak 2011-05-04 14:59:01 UTC
Reproduced on x86_64/RHEL5 with ruby-rhubarb-0.2.7-1:

#!/bin/ruby

require 'rhubarb/rhubarb'

class Create
  include Rhubarb::Persisting
  declare_column :name, :string
end

class Group
  include Rhubarb::Persisting
  declare_column :other, :int, references(Create, :on_delete=>:cascade)
end

class Order
  include Rhubarb::Persisting
  declare_column :group, :int
end

Rhubarb::Persistence::open(":memory:", :default, true) 
[Create, Group, Order].each do |klass|
  klass.create_table 
end

/usr/lib/ruby/site_ruby/1.8/sqlite3/errors.rb:62:in `check': near "create": syntax error (SQLite3::SQLException)
	from /usr/lib/ruby/site_ruby/1.8/sqlite3/statement.rb:39:in `initialize'
	from /usr/lib/ruby/site_ruby/1.8/sqlite3/database.rb:154:in `new'
	from /usr/lib/ruby/site_ruby/1.8/sqlite3/database.rb:154:in `prepare'
	from /usr/lib/ruby/site_ruby/1.8/sqlite3/database.rb:181:in `execute'
	from /usr/lib/ruby/site_ruby/1.8/rhubarb/classmixins.rb:261:in `create_table'
	from test.rb:22
	from test.rb:21:in `each'
	from test.rb:21

Comment 5 Tomas Rusnak 2011-05-04 15:04:19 UTC
Retested over all supported platforms x86,x86_64/RHEL5,RHEL6 with:

ruby-rhubarb-0.3.0-2

require 'rhubarb/rhubarb'
true

class Create
  include Rhubarb::Persisting
  declare_column :name, :string
end
#<Proc:0x00002b2796a1abd8@/usr/lib/ruby/site_ruby/1.8/rhubarb/classmixins.rb:181>

class Group
  include Rhubarb::Persisting
  declare_column :other, :int, references(Create, :on_delete=>:cascade)
end
[#<Proc:0x00002b2796a0fd50@/usr/lib/ruby/site_ruby/1.8/rhubarb/classmixins.rb:214>]

class Order
  include Rhubarb::Persisting
  declare_column :group, :int
end
#<Proc:0x00002b2796a1abd8@/usr/lib/ruby/site_ruby/1.8/rhubarb/classmixins.rb:181>

Rhubarb::Persistence::open(":memory:", :default, true) 
#<SQLite3::Database:0x2b2796d9c108 @driver=#<SQLite3::Driver::Native::Driver:0x2b2796d9bfa0 @busy_handler={}, @authorizer={}, @callback_data={}, @trace={}>, @transaction_active=false, @closed=false, @handle=#<SWIG::TYPE_p_sqlite3:0x2b2796d62750>, @translator=nil, @statement_factory=SQLite3::Statement, @type_translation=true, @results_as_hash=true>
[Create, Group, Order].each do |klass|
  klass.create_table 
end
[Create, Group, Order]

Classes names can be same as SQL reserved words.

>>> VERIFIED

Comment 6 errata-xmlrpc 2011-06-23 15:42:25 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.