I've applied your diff. I also tried to fix spec/adapters/
oracle_spec.rb (creating temp table) and added check for literal
behaviour.
This is my diff:
diff --git a/lib/sequel/adapters/shared/oracle.rb b/lib/sequel/
adapters/shared/oracle.rb
index 41b5b76..7281353 100644
--- a/lib/sequel/adapters/shared/oracle.rb
+++ b/lib/sequel/adapters/shared/oracle.rb
@@ -51,6 +51,11 @@ module Sequel
def as_sql(expression, aliaz)
"#{expression} #{quote_identifier(aliaz)}"
end
+
+ # Oracle uses the SQL standard of only doubling ' inside
strings
+ def literal_string(v)
+ "'#{v.gsub("'", "''")}'"
+ end
def select_clause_order
SELECT_CLAUSE_ORDER
diff --git a/spec/adapters/oracle_spec.rb b/spec/adapters/
oracle_spec.rb
index d532473..210e580 100644
--- a/spec/adapters/oracle_spec.rb
+++ b/spec/adapters/oracle_spec.rb
@@ -4,9 +4,21 @@ unless defined?(ORACLE_DB)
ORACLE_DB = Sequel.connect('oracle://hr:h...@localhost/XE')
end
+def ORACLE_DB.sqls
+ (@sqls ||= [])
+end
+logger = Object.new
+def logger.method_missing(m, msg)
+ ORACLE_DB.sqls << msg
+end
+ORACLE_DB.logger = logger
+
if ORACLE_DB.table_exists?(:items)
ORACLE_DB.drop_table :items
end
+if ORACLE_DB.table_exists?(:test_tmp)
+ ORACLE_DB.drop_table :test_tmp
+end
ORACLE_DB.create_table :items do
varchar2 :name, :size => 50
number :value, :size => 38
@@ -60,15 +72,16 @@ context "An Oracle database" do
end
specify "should create a temporary table" do
- ORACLE_DB.create_table :test_tmp, :temporary => true do
- primary_key :id, :integer, :null => false
- column :name, :text
+ ORACLE_DB.sqls.clear
+ ORACLE_DB.create_table :test_tmp, :temp => true do
+ primary_key :id, :integer, :null => false, :auto_increment =>
false
+ column :name, :integer
index :name, :unique => true
end
ORACLE_DB.sqls.should == [
- 'CREATE GLOBAL TEMPORARY TABLE test_tmp (id integer NOT NULL
PRIMARY KEY AUTOINCREMENT, name text)',
- 'CREATE UNIQUE INDEX test_tmp_name_index ON test_tmp (name)'
+ 'CREATE GLOBAL TEMPORARY TABLE TEST_TMP (ID integer NOT NULL
PRIMARY KEY, NAME integer)',
+ 'CREATE UNIQUE INDEX TEST_TMP_NAME_INDEX ON TEST_TMP (NAME)'
]
end
end
@@ -174,7 +187,6 @@ context "An Oracle dataset" do
{:name => 'abc', :value => 456},
{:name => 'def', :value => 789}
]
-
end
specify "should update records correctly" do
@@ -196,7 +208,11 @@ context "An Oracle dataset" do
@d[:name => 'def'][:date_created].should == Time.parse
('2009-09-09')
end
-
+
+ specify "should literalize strings correctly" do
+ @d.literal("\\'").should == "'\\'''"
+ end
+
specify "should delete records correctly" do
@d << {:name => 'abc', :value => 123}
@d << {:name => 'abc', :value => 456}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---