Skip to content

Instantly share code, notes, and snippets.

@Freaky
Created July 22, 2015 23:14
Show Gist options
  • Save Freaky/c1579de57ab9d9b9e5a5 to your computer and use it in GitHub Desktop.
Save Freaky/c1579de57ab9d9b9e5a5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'sequel'
DB = Sequel.connect "jdbc:postgresql://localhost/"
DB.extension :pg_array
DB.run("create temp table foo (bla text[])")
x = DB[:foo].prepare(:insert, :foo_insert, bla: :$bla)
x.call(bla: Sequel.pg_array(['moo']))
__END__
org/postgresql/jdbc2/AbstractJdbc2Statement.java:1934:in `setObject': org.postgresql.util.PSQLException: Can't infer the SQL type to use for an instance of org.jruby.RubyBasicObject. Use setObject() with an explicit Types value to specify the type to use.
from org/postgresql/jdbc3g/AbstractJdbc3gStatement.java:36:in `setObject'
from org/postgresql/jdbc4/AbstractJdbc4Statement.java:48:in `setObject'
from java/lang/reflect/Method.java:497:in `invoke'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/adapters/jdbc.rb:586:in `set_ps_arg'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/adapters/jdbc.rb:427:in `block in execute_prepared_statement'
from org/jruby/RubyArray.java:1560:in `each'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/adapters/jdbc.rb:427:in `block in execute_prepared_statement'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/connection_pool/threaded.rb:103:in `hold'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/database/connecting.rb:254:in `synchronize'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/adapters/jdbc.rb:415:in `execute_prepared_statement'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/adapters/jdbc.rb:244:in `execute'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/dataset/actions.rb:921:in `execute'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/dataset/prepared_statements.rb:31:in `execute'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/adapters/jdbc.rb:721:in `fetch_rows'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/adapters/shared/postgres.rb:1212:in `run'
from /home/freaky/.rbenv/versions/jruby-9.0.0.0/lib/ruby/gems/shared/gems/sequel-4.24.0/lib/sequel/dataset/prepared_statements.rb:53:in `call'
from meh.rb:9:in `<top>'
from java/lang/invoke/MethodHandle.java:625:in `invokeWithArguments'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment