Monday, May 3, 2010

[Rails] mysql adapter & 2 statments

Hi,

I have an error with mysql adapter when where is two statment in the
same sql execution.
I don't have this error with postgres adapter.

If I perform, on the console, this "stupide" code :

> db = ctiveRecord::Base.connection
> db.execute(" db.execute("CREATE TABLE toto (id int); DROP TABLE toto;")

I have the error :

//////////////////

ActiveRecord::StatementInvalid: Mysql::Error: You have an error in your
SQL syntax; check the manual that corresponds to your MySQL server
version for the right syntax to use near 'DROP TABLE toto' at line 1:
CREATE TABLE toto (id int); DROP TABLE toto;
from
/Library/WebServer/Documents/RubyTimeNetV2/vendor/plugins/rows_logger/init.rb:36:in
`log'
from
/Library/WebServer/Documents/RubyTimeNetV2/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:304:in
`execute_without_query_stats'
from
/Library/WebServer/Documents/RubyTimeNetV2/vendor/plugins/query_stats/lib/query_stats/recorder.rb:16:in
`execute'
from
/Library/WebServer/Documents/RubyTimeNetV2/vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in
`realtime'
from
/Library/WebServer/Documents/RubyTimeNetV2/vendor/plugins/query_stats/lib/query_stats/recorder.rb:15:in
`execute'
from (irb):116

////////////////

If I separate the two (stupids) statment, no error :

>> db.execute("CREATE TABLE toto (id int);")
=> nil
>> db.execute("DROP table toto;")
=> nil

Thanks

Laurent
--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment