rgeo / activerecord-mysql2spatial-adapter

ActiveRecord connection adapter for MySQL Spatial Extensions, based on mysql2 and rgeo
48 stars 64 forks source link

Rails 3.2.x not Preparing Insert Properly #5

Closed mobileoverlord closed 12 years ago

mobileoverlord commented 12 years ago

When using the mysql2spatial adaptor all my insert statements are left with the ? when trying to run the SQL.

ActiveRecord::StatementInvalid: Mysql2::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 '?, ?, ?)' at line 1: INSERT INTO `locations` (`latlon`, `path`, `shape`) VALUES (?, ?, ?)
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `query'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `block in execute'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activesupport-3.2.6/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `execute'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:211:in `execute'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:234:in `exec_insert'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/relation.rb:66:in `insert'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/persistence.rb:363:in `create'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/timestamp.rb:57:in `create'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/callbacks.rb:268:in `block in create'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:403:in `_run__4187198241703463154__create__2111829146321528765__callbacks'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback'
... 11 levels...
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/validations.rb:50:in `save'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/attribute_methods/dirty.rb:22:in `save'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/transactions.rb:241:in `block (2 levels) in save'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/transactions.rb:208:in `transaction'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/transactions.rb:241:in `block in save'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/activerecord-3.2.6/lib/active_record/transactions.rb:240:in `save'
    from (irb):3
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p194@basin/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'1.9.3-p194
ghazel commented 12 years ago

This is addressed by #4. Probably can close this as a duplicate.