Permalink
Browse files

Merge pull request #69 from trptcolin/trailing_newline_defaults

Handle trailing newline in default strings
  • Loading branch information...
tenderlove committed Oct 31, 2012
2 parents c4cbb8c + 7fec340 commit f87d5bcaa01fa8710d64768800e090c428e864d0
Showing with 5 additions and 3 deletions.
  1. +2 −2 lib/sqlite3/pragmas.rb
  2. +3 −1 test/test_integration.rb
View
@@ -269,9 +269,9 @@ def tweak_default(hash)
case hash["dflt_value"]
when /^null$/i
hash["dflt_value"] = nil
- when /^'(.*)'$/
+ when /^'(.*)'$/m
hash["dflt_value"] = $1.gsub(/''/, "'")
- when /^"(.*)"$/
+ when /^"(.*)"$/m
hash["dflt_value"] = $1.gsub(/""/, '"')
end
end
View
@@ -21,12 +21,14 @@ def test_table_info_with_type_translation_active
def test_table_info_with_defaults_for_version_3_3_8_and_higher
@db.transaction do
- @db.execute "create table defaults_test ( a string default NULL, b string default 'Hello' )"
+ @db.execute "create table defaults_test ( a string default NULL, b string default 'Hello', c string default '--- []\n' )"
data = @db.table_info( "defaults_test" )
assert_equal({"name" => "a", "type" => "string", "dflt_value" => nil, "notnull" => 0, "cid" => 0, "pk" => 0},
data[0])
assert_equal({"name" => "b", "type" => "string", "dflt_value" => "Hello", "notnull" => 0, "cid" => 1, "pk" => 0},
data[1])
+ assert_equal({"name" => "c", "type" => "string", "dflt_value" => "--- []\n", "notnull" => 0, "cid" => 2, "pk" => 0},
+ data[2])
end
end

0 comments on commit f87d5bc

Please sign in to comment.