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:
Fixed in master.
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.
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
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
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