Merge pull request #2204 from opf/feature/remove-sqlite3-dependency

Remove sqlite3 dependency, broken SQLite support
pull/2247/merge
kgalli 10 years ago
commit 9b9388a872
  1. 3
      .gitignore
  2. 8
      Gemfile
  3. 3
      Gemfile.lock
  4. 4
      config/database.yml.example
  5. 30
      config/environments/test_sqlite3.rb
  6. 4
      doc/operation_guides/manual/ubuntu-trusty-14-04-lts-and-debian-wheezy-7-7-production.md
  7. 13
      lib/chili_project/database.rb
  8. 6
      lib/tasks/ci.rake
  9. 61
      test/unit/lib/chili_project/database_test.rb

3
.gitignore vendored

@ -35,9 +35,6 @@
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

@ -198,10 +198,6 @@ platforms :mri, :mingw do
group :postgres do
gem 'pg', "~> 0.17.1"
end
group :sqlite do
gem "sqlite3"
end
end
platforms :jruby do
@ -214,10 +210,6 @@ platforms :jruby do
group :postgres do
gem "activerecord-jdbcpostgresql-adapter"
end
group :sqlite do
gem "activerecord-jdbcsqlite3-adapter"
end
end
# Load Gemfile.local, Gemfile.plugins and plugins' Gemfiles

@ -369,7 +369,6 @@ GEM
simplecov-html (~> 0.7.1)
simplecov-html (0.7.1)
slop (3.5.0)
sqlite3 (1.3.7)
strong_parameters (0.2.1)
actionpack (~> 3.0)
activemodel (~> 3.0)
@ -415,7 +414,6 @@ PLATFORMS
DEPENDENCIES
activerecord-jdbcmysql-adapter
activerecord-jdbcpostgresql-adapter
activerecord-jdbcsqlite3-adapter
activerecord-tableless (~> 1.0)
acts_as_list (~> 0.2.0)
awesome_nested_set
@ -492,7 +490,6 @@ DEPENDENCIES
simplecov (= 0.8.0.pre)
sprockets!
sprockets-rails!
sqlite3
strong_parameters
svg-graph
syck

@ -62,7 +62,3 @@ test:
#pool: 5
#username: openproject
#password:
#test_sqlite3:
#adapter: sqlite3
#database: db/test.sqlite3

@ -1,30 +0,0 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
instance_eval File.read(File.join(File.dirname(__FILE__), 'test.rb'))

@ -25,14 +25,14 @@ Install tools needed to compile Ruby and run OpenProject:
```bash
[root@debian] apt-get update
[root@debian] apt-get install git curl build-essential zlib1g-dev libyaml-dev libssl-dev libmysqlclient-dev libpq-dev libsqlite3-dev memcached libffi5
[root@debian] apt-get install git curl build-essential zlib1g-dev libyaml-dev libssl-dev libmysqlclient-dev libpq-dev memcached libffi5
```
### Only on Ubuntu
```bash
[root@ubuntu] apt-get update
[root@ubuntu] apt-get install git curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libmysqlclient-dev libpq-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties memcached libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
[root@ubuntu] apt-get install git curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libmysqlclient-dev libpq-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties memcached libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
```
### Debian and Ubuntu

@ -39,8 +39,7 @@ module ChiliProject
def self.supported_adapters
@adapters ||= ({
mysql: /mysql/i,
postgresql: /postgres/i,
sqlite: /sqlite/i
postgresql: /postgres/i
})
end
@ -75,16 +74,6 @@ module ChiliProject
when :postgresql
version = ActiveRecord::Base.connection.select_value('SELECT version()')
raw ? version : version.match(/\APostgreSQL (\S+)/i)[1]
when :sqlite
if Object.const_defined?('RUBY_ENGINE') && ::RUBY_ENGINE == 'jruby'
Jdbc::SQLite3::VERSION
else
if SQLite3.const_defined? 'SQLITE_VERSION'
SQLite3::SQLITE_VERSION
else
SQLite3::Driver::Native::API.sqlite3_libversion
end
end
end
end
end

@ -47,7 +47,7 @@ namespace :ci do
RAILS_ENV = 'test'
db_adapter = ENV['DB']
raise 'please provide a db adapter with DB={mysql2, postgres, sqlite}' unless db_adapter
raise 'please provide a db adapter with DB={mysql2, postgres}' unless db_adapter
db_info = {
'mysql2' => {
@ -57,10 +57,6 @@ namespace :ci do
'postgres' => {
'adapter' => 'postgresql',
'username' => 'postgres'
},
'sqlite' => {
'adapter' => 'sqlite3',
'database' => 'db/test.sqlite3'
}
}[db_adapter]

@ -30,71 +30,16 @@ require File.expand_path('../../../../test_helper', __FILE__)
class ChiliProject::DatabaseTest < ActiveSupport::TestCase
setup do
ChiliProject::Database.stub(:adapter_name).and_return 'SQLite'
ChiliProject::Database.stub(:adapter_name).and_return 'PostgresQL'
end
should 'return the correct identifier' do
assert_equal :sqlite, ChiliProject::Database.name
assert_equal :postgresql, ChiliProject::Database.name
end
should 'be able to use the helper methods' do
assert_equal false, ChiliProject::Database.mysql?
assert_equal false, ChiliProject::Database.postgresql?
assert_equal true, ChiliProject::Database.sqlite?
end
should 'return a version string for SQLite3' do
begin
ChiliProject::Database.stub(:adapter_name).and_return 'SQLite'
if Object.const_defined?('RUBY_ENGINE') && ::RUBY_ENGINE == 'jruby'
# If we have the SQLite3 gem installed, save the old constant
if Object.const_defined?('Jdbc') && Jdbc::SQLite3.const_defined?('SQLite3')
sqlite3_version = Jdbc::SQLite3::VERSION
# else create the module for this test
else
module ::Jdbc; module SQLite3; end ;end
created_module = true
end
silence_warnings { ::Jdbc::SQLite3.const_set('VERSION', "1.2.3") }
else
# If we run the tests on a newer SQLite3, stub the VERSION constant
if Object.const_defined?('SQLite3') && SQLite3.const_defined?('SQLITE_VERSION')
sqlite3_version = SQLite3::SQLITE_VERSION
silence_warnings { ::SQLite3.const_set('SQLITE_VERSION', "1.2.3") }
# On an older SQLite3, stub the C-provided sqlite3_libversion method
elsif %w(SQLite3 Driver Native API).inject(Object){ |m, defined|
m = (m && m.const_defined?(defined)) ? m.const_get(defined) : false
}
SQLite3::Driver::Native::API.stub('sqlite3_libversion').and_return "1.2.3"
# Fallback if nothing else worked: Stub the old SQLite3 API
else
# if we don't have any sqlite3 module, stub the whole module
module ::SQLite3; module Driver; module Native; module API
def self.sqlite3_libversion; "1.2.3"; end
end; end; end; end
created_module = true
end
end
assert_equal "1.2.3", ChiliProject::Database.version
assert_equal "1.2.3", ChiliProject::Database.version(true)
ensure
# Clean up after us
if Object.const_defined?('RUBY_ENGINE') && ::RUBY_ENGINE == 'jruby'
if created_module
Jdbc.instance_eval{remove_const 'SQLite3' }
elsif sqlite3_version
silence_warnings { Jdbc::SQLite3.const_set('VERSION', sqlite3_version) }
end
else
if created_module
Object.instance_eval{remove_const 'SQLite3' }
elsif sqlite3_version
silence_warnings { SQLite3.const_set('SQLITE_VERSION', sqlite3_version) }
end
end
end
assert_equal true, ChiliProject::Database.postgresql?
end
should 'return a version string for PostgreSQL' do

Loading…
Cancel
Save