Rails on Oracle 2011
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Rails on Oracle 2011

on

  • 14,412 views

RailsConf 2011 BoF session "Rails on Oracle" slides

RailsConf 2011 BoF session "Rails on Oracle" slides

Statistics

Views

Total Views
14,412
Views on SlideShare
4,693
Embed Views
9,719

Actions

Likes
0
Downloads
26
Comments
0

14 Embeds 9,719

http://blog.rayapps.com 9560
http://localhost:4000 74
http://localhost 45
http://translate.googleusercontent.com 16
url_unknown 6
http://www.slideshare.net 3
http://www.techgig.com 3
http://feeds.feedburner.com 3
http://webcache.googleusercontent.com 3
http://www.hanrss.com 2
http://www.newsblur.com 1
http://www.m.techgig.com 1
http://honyaku.yahoofs.jp 1
http://www.365dailyjournal.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Rails on Oracle 2011 Presentation Transcript

  • 1. Rails on Oracle
  • 2. Raimonds Simanovskis github.com/rsim @rsim
  • 3. Self-promotion :) eazybi.com
  • 4. How to contribute to ActiveRecord Oracle enhanced adapter
  • 5. Main components Rails 3.x build query ActiveRecord Arel SQL Arel::Visitors::Oracle execute resultsOracleEnhancedAdapter ActiveRecord:: ConnectionAdapters:: AbstractAdapter
  • 6. What Oracle Enhanced adapter does database metadata custom CUD connection queries procedures schema customvalue quoting definition stmts schema stmtscolumn type context index schema dump mapping creationresults type structure AR patches mapping dump
  • 7. Oracle Data Types Ruby Rails Oracle Fixnum :integer NUMBER Float :float NUMBER BigDecimal :decimal NUMBER, DECIMAL Time :datetime DATE Time :time DATE Date :date DATE String :string VARCHAR2 String :text CLOB String :binary BLOBTrue/FalseClass :boolean NUMBER(1), CHAR(1)
  • 8. Latest additionRuby Rails OracleString :raw RAW
  • 9. Legacy schemasclass Employee < ActiveRecord::Base set_table_name "hr_employees" set_primary_key "employee_id" set_sequence_name "hr_employee_s" set_date_columns :hired_on, :birth_date_on set_datetime_columns :last_login_time set_boolean_columns :manager, :active ignore_table_columns :attribute1, :attribute2end
  • 10. class Employee < ActiveRecord::Base set_create_method do plsql.employees_pkg.create_employee( :p_first_name => first_name,ActiveRecord :p_last_name => last_name, :p_employee_id => nil )[:p_employee_id] with end set_update_method do PL/SQL plsql.employees_pkg.update_employee( :p_employee_id => id, :p_first_name => first_name, CRUD ) :p_last_name => last_name procedures end set_delete_method do plsql.employees_pkg.delete_employee( :p_employee_id => id ) end end
  • 11. Full-text indexesadd_context_index :posts, [:title, :body, # specify aliases always with AS keyword "SELECT comments.author AS comment_author, " + "comments.body AS comment_body " + "FROM comments WHERE comments.post_id = :id" ], :name => post_and_comments_index, :index_column => :all_text, :index_column_trigger_on => [:updated_at, :comments_count], :sync => ON COMMITPost.contains(:all_text, "hello")Post.contains(:all_text, "{first} within title")Post.contains(:all_text, "{first} AND {post}")
  • 12. Gemfilegem “ruby-oci8”, “~>2.0.4”gem “activerecord-oracle_enhanced-adapter”, “~>1.3.2”gem “activerecord-oracle_enhanced-adapter”, :git=> “git://github.com/rsim/oracle-enhanced.git”
  • 13. Currently testing onActiveRecord versions 2.3.x 3.0.x 3.1.beta
  • 14. Currently testing on Oracle versions 10.2.0.4 11gR2 should be OK :)
  • 15. Currently testing on Ruby platforms oracle_enhanced adapter Ruby 1.8.7 Ruby 1.9.2 JRuby 1.6ruby-oci8 2.0.4 ruby-oci8 2.0.4 ojdbc6.jar
  • 16. Reporting issues
  • 17. Where? http://github.com/rsim/oracle-enhanced/issueshttp://groups.google.com/group/oracle-enhanced
  • 18. How? Provide full examplerequire "rubygems"gem "activerecord", "3.0.5"gem "activerecord-oracle_enhanced-adapter", "1.3.2"require "active_record"ActiveRecord::Base.establish_connection(:adapter => "oracle_enhanced", :database => "orcl", :username => "hr", :password => "hr")ActiveRecord::Base.connection.instance_eval do drop_table :test_categories rescue nil create_table :test_categories, :force => true do |t| t.string :name t.string :category_code endendclass TestCategory < ActiveRecord::Baseendcategory = TestCategory.new(:name=>"hl", :category_code=>"hd")category.id = 1category.save!p category
  • 19. IdeallyGithub pull request
  • 20. Other libraries
  • 21. ruby-plsql gemplsql.connect! "hr","hr","xe"plsql.test_uppercase(xxx) # => "XXX"plsql.test_uppercase(:p_string => xxx) # => "XXX"plsql.test_copy("abc", nil, nil) # => { :p_to => "abc", # :p_to_double => "abcabc" }plsql.test_copy(:p_from => "abc", :p_to => nil, :p_to_double => nil) # => { :p_to => "abc", # :p_to_double => "abcabc" }plsql.hr.test_uppercase(xxx) # => "XXX"plsql.test_package.test_uppercase(xxx) # => XXXplsql.hr.test_package.test_uppercase(xxx) # => XXXplsql.logoff
  • 22. ruby-plsql-spec ideal language for writing tests powerful testing tools RSpec with “readable” syntax library for callingruby-plsql PL/SQL procedures from Ruby
  • 23. http://github.com/rsim/mondrian-olap
  • 24. More information http://blog.rayapps.com http://github.com/rsim/oracle-enhancedhttp://groups.google.com/group/oracle-enhanced