From 49032a99c6c5c526866c38ca901292a3eb90c02c Mon Sep 17 00:00:00 2001 From: Matthias Tarasiewicz Date: Thu, 8 Feb 2007 22:01:36 +0000 Subject: [PATCH] svn:external rails updated to 1.2.2 fixed ticket #372 typo in db-query sqlite3-ruby updated to 1.2.1 --- app/models/web.rb | 2 +- config/environment.rb | 2 +- .../plugins/sqlite3-ruby/sqlite3/pragmas.rb | 51 ++++++++++++++++++- .../plugins/sqlite3-ruby/sqlite3/version.rb | 3 +- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/app/models/web.rb b/app/models/web.rb index d1d50268..d9aff5ed 100644 --- a/app/models/web.rb +++ b/app/models/web.rb @@ -23,7 +23,7 @@ class Web < ActiveRecord::Base 'FROM revisions r ' + 'JOIN pages p ON p.id = r.page_id ' + 'WHERE p.web_id = ' + self.id.to_s + - 'ORDER by 1 ' + ' ORDER by 1 ' ).collect { |row| row['author'] } end diff --git a/config/environment.rb b/config/environment.rb index 24e89a88..ecee8155 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -7,7 +7,7 @@ Rails::Initializer.run do |config| # Use the database for sessions instead of the file system # (create the session table with 'rake create_sessions_table') - config.action_controller.session_store = :active_record_store + #config.action_controller.session_store = :active_record_store # Enable page/fragment caching by setting a file-based store # (remember to create the caching directory and make it readable to the application) diff --git a/vendor/plugins/sqlite3-ruby/sqlite3/pragmas.rb b/vendor/plugins/sqlite3-ruby/sqlite3/pragmas.rb index 72473871..20b31800 100644 --- a/vendor/plugins/sqlite3-ruby/sqlite3/pragmas.rb +++ b/vendor/plugins/sqlite3-ruby/sqlite3/pragmas.rb @@ -246,9 +246,56 @@ module SQLite3 end def table_info( table, &block ) # :yields: row - get_query_pragma "table_info", table, &block + columns, *rows = execute2("PRAGMA table_info(#{table})") + + needs_tweak_default = version_compare(driver.libversion, "3.3.7") > 0 + + result = [] unless block_given? + rows.each do |row| + new_row = {} + columns.each_with_index do |name, index| + new_row[name] = row[index] + end + + tweak_default(new_row) if needs_tweak_default + + if block_given? + yield new_row + else + result << new_row + end + end + + result end - + + private + + # Compares two version strings + def version_compare(v1, v2) + v1 = v1.split(".").map { |i| i.to_i } + v2 = v2.split(".").map { |i| i.to_i } + parts = [v1.length, v2.length].max + v1.push 0 while v1.length < parts + v2.push 0 while v2.length < parts + v1.zip(v2).each do |a,b| + return -1 if a < b + return 1 if a > b + end + return 0 + end + + # Since SQLite 3.3.8, the table_info pragma has returned the default + # value of the row as a quoted SQL value. This method essentially + # unquotes those values. + def tweak_default(hash) + case hash["dflt_value"] + when /^null$/i then + hash["dflt_value"] = nil + when /^'(.*)'$/ + hash["dflt_value"] = $1.gsub(/''/, "'") + end + end end end diff --git a/vendor/plugins/sqlite3-ruby/sqlite3/version.rb b/vendor/plugins/sqlite3-ruby/sqlite3/version.rb index 12e678b0..2398c0ac 100644 --- a/vendor/plugins/sqlite3-ruby/sqlite3/version.rb +++ b/vendor/plugins/sqlite3-ruby/sqlite3/version.rb @@ -36,9 +36,10 @@ module SQLite3 MAJOR = 1 MINOR = 2 - TINY = 0 + TINY = 1 STRING = [ MAJOR, MINOR, TINY ].join( "." ) + #:beta-tag: end