This is my first rails app with a legacy database and I''m having a
terrible time getting the models set up correctly. I have an order
table that has a primary field named order_number. I have a name table
with a primary of item_number. These two tables are liked by the
item_number and the order_number, but not as you might think. If the
order_number is 2500, then each entry in the name table will have it''s
item number incremented by 1 (i.e. 2501,2501,2503). Here are my models
class Order < ActiveRecord::Base
set_table_name :order
set_primary_key :order_number
has_many :name, :finder_sql => ''SELECT * from name
where name.item_number like
CONCAT(SUBSTRING(#{order_number},1,14),\''%\'')''
end
~
class Name < ActiveRecord::Base
set_table_name :name
set_primary_key :item_number
belongs_to :order, :finder_sql => ''SELECT * from order
where order.order_number =
CONCAT(SUBSTRING(app_name.#{item_number},1,14),\''00\'')''
end
These produce the following errors.
ArgumentError (Unknown key(s): finder_sql):
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/hash/keys.rb:48:in
`assert_valid_keys''
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:519:in
`belongs_to_without_reflection''
(eval):5:in `belongs_to''
/app/models/name.rb:4
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:355:in
`has_many_without_reflection''
(eval):5:in `has_many''
/app/models/order.rb:4
Can anyone help me out with this?
--
Posted via http://www.ruby-forum.com/.
Hi, charlie, as a first step please change set_primary_key :order_number to set_primary_key "order_number" (and the like for :item_number) it might well be that assert_valid_keys is stumbling on these. Best Regards Jan Prill charlie bowman wrote:> This is my first rails app with a legacy database and I''m having a > terrible time getting the models set up correctly. I have an order > table that has a primary field named order_number. I have a name table > with a primary of item_number. These two tables are liked by the > item_number and the order_number, but not as you might think. If the > order_number is 2500, then each entry in the name table will have it''s > item number incremented by 1 (i.e. 2501,2501,2503). Here are my models > > class Order < ActiveRecord::Base > set_table_name :order > set_primary_key :order_number > has_many :name, :finder_sql => ''SELECT * from name > where name.item_number like > CONCAT(SUBSTRING(#{order_number},1,14),\''%\'')'' > > end > ~ > class Name < ActiveRecord::Base > set_table_name :name > set_primary_key :item_number > belongs_to :order, :finder_sql => ''SELECT * from order > where order.order_number = > CONCAT(SUBSTRING(app_name.#{item_number},1,14),\''00\'')'' > end > > > These produce the following errors. > > ArgumentError (Unknown key(s): finder_sql): > /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/hash/keys.rb:48:in > `assert_valid_keys'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:519:in > `belongs_to_without_reflection'' > (eval):5:in `belongs_to'' > /app/models/name.rb:4 > /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:355:in > `has_many_without_reflection'' > (eval):5:in `has_many'' > /app/models/order.rb:4 > > Can anyone help me out with this? > >
Hi, charlie, why is it has_many :name (and not names) is pluralization turned off? Best regards Jan charlie bowman wrote:> This is my first rails app with a legacy database and I''m having a > terrible time getting the models set up correctly. I have an order > table that has a primary field named order_number. I have a name table > with a primary of item_number. These two tables are liked by the > item_number and the order_number, but not as you might think. If the > order_number is 2500, then each entry in the name table will have it''s > item number incremented by 1 (i.e. 2501,2501,2503). Here are my models > > class Order < ActiveRecord::Base > set_table_name :order > set_primary_key :order_number > has_many :name, :finder_sql => ''SELECT * from name > where name.item_number like > CONCAT(SUBSTRING(#{order_number},1,14),\''%\'')'' > > end > ~ > class Name < ActiveRecord::Base > set_table_name :name > set_primary_key :item_number > belongs_to :order, :finder_sql => ''SELECT * from order > where order.order_number = > CONCAT(SUBSTRING(app_name.#{item_number},1,14),\''00\'')'' > end > > > These produce the following errors. > > ArgumentError (Unknown key(s): finder_sql): > /usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/hash/keys.rb:48:in > `assert_valid_keys'' > /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:519:in > `belongs_to_without_reflection'' > (eval):5:in `belongs_to'' > /app/models/name.rb:4 > /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:355:in > `has_many_without_reflection'' > (eval):5:in `has_many'' > /app/models/order.rb:4 > > Can anyone help me out with this? > >
charlie bowman
2006-Jan-17 18:17 UTC
[Rails] Re: legacy database and finder_sql nightmare!
Jan Prill wrote:> Hi, charlie, > > as a first step please change set_primary_key :order_number to > set_primary_key "order_number" (and the like for :item_number) it might > well be that assert_valid_keys is stumbling on these. > > Best Regards > Jan PrillI changed this but it didn''t help.>why is it has_many :name (and not names) is pluralization turned off?I have it singular because the table name is actually singular. That''s why I set the parameter (set_table_name :order). This is the correct method, correct? -- Posted via http://www.ruby-forum.com/.
Hi, charlie,
another thing.
:finder_sql isn''t a supported option for belongs_to:
def belongs_to(association_id, options = {})
options.assert_valid_keys(:class_name, :foreign_key, :remote, :conditions,
:order, :include, :dependent, :counter_cache, :extend)
...
Beyond that :order is kind of a reserved word at least on relationships.
Don''t know if this causes problems as well, but the first one you need
to change is finder_sql.
Regards
Jan
try to
charlie bowman wrote:> This is my first rails app with a legacy database and I''m having a
> terrible time getting the models set up correctly. I have an order
> table that has a primary field named order_number. I have a name table
> with a primary of item_number. These two tables are liked by the
> item_number and the order_number, but not as you might think. If the
> order_number is 2500, then each entry in the name table will have
it''s
> item number incremented by 1 (i.e. 2501,2501,2503). Here are my models
>
> class Order < ActiveRecord::Base
> set_table_name :order
> set_primary_key :order_number
> has_many :name, :finder_sql => ''SELECT * from name
> where name.item_number like
> CONCAT(SUBSTRING(#{order_number},1,14),\''%\'')''
>
> end
> ~
> class Name < ActiveRecord::Base
> set_table_name :name
> set_primary_key :item_number
> belongs_to :order, :finder_sql => ''SELECT * from order
> where order.order_number =
>
CONCAT(SUBSTRING(app_name.#{item_number},1,14),\''00\'')''
> end
>
>
> These produce the following errors.
>
> ArgumentError (Unknown key(s): finder_sql):
>
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/hash/keys.rb:48:in
> `assert_valid_keys''
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:519:in
> `belongs_to_without_reflection''
> (eval):5:in `belongs_to''
> /app/models/name.rb:4
>
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:355:in
> `has_many_without_reflection''
> (eval):5:in `has_many''
> /app/models/order.rb:4
>
> Can anyone help me out with this?
>
>
I think it is quite likely that you have to overwrite things like
ActiveRecord::Associations.association_join
1066
def association_join(reflection)
1067
case reflection.macro
1068
when :has_and_belongs_to_many
1069
" LEFT OUTER JOIN
#{reflection.options[:join_table]} ON " +
1070
"#{reflection.options[:join_table]}.#{reflection.options[:foreign_key]
|| table_name.classify.foreign_key} = " +
1071
"#{table_name}.#{primary_key}
" +
1072
" LEFT OUTER JOIN
#{reflection.klass.table_name} ON " +
1073
"#{reflection.options[:join_table]}.#{reflection.options[:association_foreign_key]
|| reflection.klass.table_name.classify.foreign_key} = " +
1074
"#{reflection.klass.table_name}.#{reflection.klass.primary_key}
"
1075
when :has_many, :has_one
1076
" LEFT OUTER JOIN
#{reflection.klass.table_name} ON " +
1077
"#{reflection.klass.table_name}.#{reflection.options[:foreign_key]
|| table_name.classify.foreign_key} = " +
1078
"#{table_name}.#{primary_key}
"
1079
when :belongs_to
1080
" LEFT OUTER JOIN
#{reflection.klass.table_name} ON " +
1081
"#{reflection.klass.table_name}.#{reflection.klass.primary_key}
= " +
1082
"#{table_name}.#{reflection.options[:foreign_key]
|| reflection.klass.table_name.classify.foreign_key} "
1083
else
1084
""
1085
end
1086
end
Best Regards
Jan Prill
charlie bowman wrote:
This is my first rails app with a legacy database and I''m having a
terrible time getting the models set up correctly. I have an order
table that has a primary field named order_number. I have a name table
with a primary of item_number. These two tables are liked by the
item_number and the order_number, but not as you might think. If the
order_number is 2500, then each entry in the name table will have it''s
item number incremented by 1 (i.e. 2501,2501,2503). Here are my models
class Order < ActiveRecord::Base
set_table_name :order
set_primary_key :order_number
has_many :name, :finder_sql => ''SELECT * from name
where name.item_number like
CONCAT(SUBSTRING(#{order_number},1,14),\''%\'')''
end
~
class Name < ActiveRecord::Base
set_table_name :name
set_primary_key :item_number
belongs_to :order, :finder_sql => ''SELECT * from order
where order.order_number =
CONCAT(SUBSTRING(app_name.#{item_number},1,14),\''00\'')''
end
These produce the following errors.
ArgumentError (Unknown key(s): finder_sql):
/usr/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/core_ext/hash/keys.rb:48:in
`assert_valid_keys''
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:519:in
`belongs_to_without_reflection''
(eval):5:in `belongs_to''
/app/models/name.rb:4
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/associations.rb:355:in
`has_many_without_reflection''
(eval):5:in `has_many''
/app/models/order.rb:4
Can anyone help me out with this?
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
charlie bowman
2006-Jan-17 19:30 UTC
[Rails] Re: legacy database and finder_sql nightmare!
Order is just a made up name, the actual table name is different. Here is my new name model, but it is still broken. Now I get a segmentaion fault and webbrick crashes. class Name < ActiveRecord::Base set_table_name "name" set_primary_key "item_number" belongs_to :order, foreign_key => ''number'', :conditions => [''item_number like CONCAT(SUBSTRING(order.order_number,1,14),''%'')''] end ~ Jan Prill wrote:> Hi, charlie, > > another thing. > > :finder_sql isn''t a supported option for belongs_to: > > def belongs_to(association_id, options = {}) > options.assert_valid_keys(:class_name, :foreign_key, :remote, > :conditions, :order, :include, :dependent, :counter_cache, :extend) > ... > > > Beyond that :order is kind of a reserved word at least on relationships. > Don''t know if this causes problems as well, but the first one you need > to change is finder_sql. > > Regards > Jan > > try to-- Posted via http://www.ruby-forum.com/.
Why are you providing the :conditions as an array? It should be a string and you need to escape single quotes or use a mixture of single and double quotes. Is there anything happening in your development.log? The first thing you need is a sql statement in your development.log, once you''ve got that you could think about workarounds fixing that sql statement. Jan charlie bowman wrote:> Order is just a made up name, the actual table name is different. > > Here is my new name model, but it is still broken. Now I get a > segmentaion fault and webbrick crashes. > > class Name < ActiveRecord::Base > set_table_name "name" > set_primary_key "item_number" > belongs_to :order, foreign_key => ''number'', > :conditions => [''item_number like > CONCAT(SUBSTRING(order.order_number,1,14),''%'')''] > > end > ~ > > > > > Jan Prill wrote: > >> Hi, charlie, >> >> another thing. >> >> :finder_sql isn''t a supported option for belongs_to: >> >> def belongs_to(association_id, options = {}) >> options.assert_valid_keys(:class_name, :foreign_key, :remote, >> :conditions, :order, :include, :dependent, :counter_cache, :extend) >> ... >> >> >> Beyond that :order is kind of a reserved word at least on relationships. >> Don''t know if this causes problems as well, but the first one you need >> to change is finder_sql. >> >> Regards >> Jan >> >> try to >> > > >
charlie bowman
2006-Jan-17 20:25 UTC
[Rails] Re: Re: legacy database and finder_sql nightmare!
the single quotes were a typo. here is the model
class Name < ActiveRecord::Base
set_table_name "name"
set_primary_key "item_number"
belongs_to :order, :conditions => ''item_number like
CONCAT(SUBSTRING(bee_order.order_number,1,14),\''%\'')''
end
I still get a segmentation fault, but I do get this in the log
Processing OrdersController#test (for 192.168.2.28 at 2006-01-17
15:23:17) [GET]
Parameters: {"action"=>"test",
"controller"=>"orders"}
BeeOrder Load (0.032550) SELECT * FROM order WHERE
(order.order_number = ''90060'') LIMIT 1
the log looks good but the server keeps crashing.
Jan Prill wrote:> Why are you providing the :conditions as an array? It should be a string
> and you need to escape single quotes or use a mixture of single and
> double quotes.
>
> Is there anything happening in your development.log? The first thing you
> need is a sql statement in your development.log, once you''ve got
that
> you could think about workarounds fixing that sql statement.
>
> Jan
--
Posted via http://www.ruby-forum.com/.
maybe it''s a webrick problem. what''s your testing system like? are you on linux, windows, osx? have you tested another server than webrick? scgi and apache are simple to set up and you maybe can track the fault down to webrick. what are the last words of webrick? Is there something like: .//script//..//config//../vendor/rails/actionpack/lib/action_controller/code_generation.rb:68: [BUG] Segmentation fault ruby 1.8.2 (2004-12-25) [i386-mswin32] that let''s you track down where the segmentation fault is happening? Best Regards Jan Prill charlie bowman wrote:> the single quotes were a typo. here is the model > > class Name < ActiveRecord::Base > set_table_name "name" > set_primary_key "item_number" > belongs_to :order, :conditions => ''item_number like > CONCAT(SUBSTRING(bee_order.order_number,1,14),\''%\'')'' > > end > > I still get a segmentation fault, but I do get this in the log > > Processing OrdersController#test (for 192.168.2.28 at 2006-01-17 > 15:23:17) [GET] > Parameters: {"action"=>"test", "controller"=>"orders"} > BeeOrder Load (0.032550) SELECT * FROM order WHERE > (order.order_number = ''90060'') LIMIT 1 > > the log looks good but the server keeps crashing. > > > > > > Jan Prill wrote: > >> Why are you providing the :conditions as an array? It should be a string >> and you need to escape single quotes or use a mixture of single and >> double quotes. >> >> Is there anything happening in your development.log? The first thing you >> need is a sql statement in your development.log, once you''ve got that >> you could think about workarounds fixing that sql statement. >> >> Jan >> > > >
charlie bowman
2006-Jan-17 20:48 UTC
[Rails] Re: Re: Re: legacy database and finder_sql nightmare!
Here is the last info from webbrick, and I have rebooted my linux box to make sure it''s not the OS. /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:325: [BUG] Segmentation fault ruby 1.8.4 (2005-12-24) [i386-linux] Jan Prill wrote:> maybe it''s a webrick problem. what''s your testing system like? are you > on linux, windows, osx? have you tested another server than webrick? > scgi and apache are simple to set up and you maybe can track the fault > down to webrick. what are the last words of webrick? Is there something > like: > > .//script//..//config//../vendor/rails/actionpack/lib/action_controller/code_generation.rb:68: > [BUG] Segmentation fault > ruby 1.8.2 (2004-12-25) [i386-mswin32] > > that let''s you track down where the segmentation fault is happening? > > Best Regards > Jan Prill-- Posted via http://www.ruby-forum.com/.
The code fragment in question is:
320
def select(sql, name = nil)
321
@connection.query_with_result
= true
322
result = execute(sql, name)
323
rows = []
324
if @null_values_in_each_hash
325
result.each_hash
{ |row| rows <<
row }
326
else
327
all_fields = result.fetch_fields.inject({}) { |fields, f|
fields[f.name] = nil; fields }
328
result.each_hash
{ |row| rows <<
all_fields.dup.update(row) }
329
end
330
result.free
331
rows
332
end
83
def initialize(connection,
logger,
connection_options, config)
84
super(connection, logger)
85
@connection_options, @config = connection_options, config
86
@null_values_in_each_hash
= Mysql.const_defined?(:VERSION)
87
connect
88
end
The adapter tries to iterate of the returned rows. Have you already
tried to execute the sql statement you found in your log on the mysql
command line?
Best Regards
Jan Prill
charlie bowman wrote:
Here is the last info from webbrick, and I have rebooted my linux box to
make sure it''s not the OS.
/usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:325:
[BUG] Segmentation fault
ruby 1.8.4 (2005-12-24) [i386-linux]
Jan Prill wrote:
maybe it''s a webrick problem. what''s your testing system like?
are you
on linux, windows, osx? have you tested another server than webrick?
scgi and apache are simple to set up and you maybe can track the fault
down to webrick. what are the last words of webrick? Is there something
like:
.//script//..//config//../vendor/rails/actionpack/lib/action_controller/code_generation.rb:68:
[BUG] Segmentation fault
ruby 1.8.2 (2004-12-25) [i386-mswin32]
that let''s you track down where the segmentation fault is happening?
Best Regards
Jan Prill
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
Jan Prill
2006-Jan-17 21:07 UTC
[Rails] Re: Re: Re: legacy database and finder_sql nightmare!
resend, because ruby-forum seems to have problems with html messages... Jan Prill wrote:> The code fragment in question is: > > 320 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L320> > def select(sql, name = nil) > 321 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L321> > @connection.query_with_result = true > 322 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L322> > result = execute(sql, name) > 323 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L323> > rows = [] > 324 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L324> > if @null_values_in_each_hash > 325 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L325> > * result.each_hash { |row| rows << row }* > 326 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L326> > else > 327 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L327> > all_fields = result.fetch_fields.inject({}) { |fields, f| > fields[f.name] = nil; fields } > 328 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L328> > result.each_hash { |row| rows << > all_fields.dup.update(row) } > 329 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L329> > end > 330 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L330> > result.free > 331 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L331> > rows > 332 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L332> > end > > > 83 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L83> > def initialize(connection, logger, connection_options, config) > 84 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L84> > super(connection, logger) > 85 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L85> > @connection_options, @config = connection_options, config > 86 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L86> > *@null_values_in_each_hash = Mysql.const_defined?(:VERSION)* > 87 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L87> > connect > 88 > <http://dev.rubyonrails.org/browser/tags/rel_1-0-0/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb#L88> > end > > > The adapter tries to iterate of the returned rows. Have you already > tried to execute the sql statement you found in your log on the mysql > command line? > > Best Regards > Jan Prill > > charlie bowman wrote: >> Here is the last info from webbrick, and I have rebooted my linux box to >> make sure it''s not the OS. >> >> >> >> >> /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/mysql_adapter.rb:325: >> [BUG] Segmentation fault >> ruby 1.8.4 (2005-12-24) [i386-linux] >> >> >> Jan Prill wrote: >> >>> maybe it''s a webrick problem. what''s your testing system like? are you >>> on linux, windows, osx? have you tested another server than webrick? >>> scgi and apache are simple to set up and you maybe can track the fault >>> down to webrick. what are the last words of webrick? Is there something >>> like: >>> >>> .//script//..//config//../vendor/rails/actionpack/lib/action_controller/code_generation.rb:68: >>> [BUG] Segmentation fault >>> ruby 1.8.2 (2004-12-25) [i386-mswin32] >>> >>> that let''s you track down where the segmentation fault is happening? >>> >>> Best Regards >>> Jan Prill >>> >> >> >> >
Jan Prill
2006-Jan-17 21:11 UTC
[Rails] Re: Re: Re: legacy database and finder_sql nightmare!
both didn''t came through to ruby-forum.com, so I''ll have
another try
through ruby-forum itself...
The code fragment in question is:
320 def select(sql, name = nil)
321 @connection.query_with_result = true
322 result = execute(sql, name)
323 rows = []
324 if @null_values_in_each_hash
325 result.each_hash { |row| rows << row }
326 else
327 all_fields = result.fetch_fields.inject({}) { |fields,
f| fields[f.name] = nil; fields }
328 result.each_hash { |row| rows <<
all_fields.dup.update(row) }
329 end
330 result.free
331 rows
332 end
83 def initialize(connection, logger, connection_options, config)
84 super(connection, logger)
85 @connection_options, @config = connection_options, config
86 @null_values_in_each_hash = Mysql.const_defined?(:VERSION)
87 connect
88 end
The adapter tries to iterate of the returned rows. Have you already
tried to execute the sql statement you found in your log on the mysql
command line?
Best Regards
Jan Prill
--
Posted via http://www.ruby-forum.com/.
charlie bowman
2006-Jan-17 21:15 UTC
[Rails] Re: Re: Re: legacy database and finder_sql nightmare!
yes it works fine from the command line. -- Posted via http://www.ruby-forum.com/.
Jan Prill
2006-Jan-17 21:40 UTC
[Rails] Re: Re: Re: legacy database and finder_sql nightmare!
Hi, charlie, ok. But rails seems to have problems with the returned resultset. Here''s what I would do: Get a source version of rails in your_project/vendor/rails which is used instead of the installed gems with rake freeze_edge (or freeze to a specific version, look at rake --tasks) and debug the segmentation fault. Something seems to be wrong with your results. After changes on vendor/rails/activerecord/lib/active_record/connec tion_adapters/mysql_adapter.rb you might have to restart webrick (no big deal since it crashes anyway ;^) Best Regards Jan Prill -- Posted via http://www.ruby-forum.com/.