I'm forced to work with a database that doesn't support
getGeneratedKeys() (Teradata 6.0). This method is called in
JdbcAdapterInternalService.java in the execute_insert method. I wanted
to squeeze my insert statement through the execute_query, but I also
wanted to keep the rails validations and to keep the rails value
quoting. My question: Is there any civilized workaround?

The only way I've been able to do this is:

in the controller:

oldmanager = @manager
oldmanager.public_validate
if (oldmanager.valid?)
  Manager.connection.raw_connection.execute_query(
      "INSERT INTO [EMAIL PROTECTED] " +
      "([EMAIL PROTECTED](', ')}) " +
      "VALUES([EMAIL PROTECTED](', ')})")
  @manager = Manager.find(:first, :conditions => {
    :Mgr_Type => @manager.Mgr_Type,
    :First_name => @manager.First_name, 
    :Last_name => @manager.Last_name, 
    :Supervisor_Mgr_id => @manager.Supervisor_Mgr_id,
    :Email => @manager.Email,
    :Phone_nbr => @manager.Phone_nbr,
    :Organization_cd => @manager.Organization_cd})
end

and some public_... methods in the Manager model

def public_quoted_attribute_values
  attributes_with_quotes.values
end
def public_quoted_column_names
  quoted_column_names
end
def public_quoted_table_name
  self.class.quoted_table_name
end
def public_validate
  validate
end

Do you have a better idea?

Antoni Mylka
[EMAIL PROTECTED]
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to