activerecord-jdbc-adapter 0.9.7-java → 1.0.0.beta1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/Manifest.txt +71 -38
- data/lib/active_record/connection_adapters/cachedb_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/derby_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/h2_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/hsqldb_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/informix_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/jdbc_adapter.rb +1 -661
- data/lib/active_record/connection_adapters/jndi_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/mssql_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/oracle_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +1 -13
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -13
- data/lib/activerecord-jdbc-adapter.rb +2 -2
- data/lib/arjdbc.rb +29 -0
- data/lib/arjdbc/cachedb.rb +3 -0
- data/lib/arjdbc/cachedb/adapter.rb +20 -0
- data/lib/arjdbc/cachedb/connection_methods.rb +10 -0
- data/lib/arjdbc/db2.rb +2 -0
- data/lib/{jdbc_adapter/jdbc_db2.rb → arjdbc/db2/adapter.rb} +1 -17
- data/lib/arjdbc/derby.rb +7 -0
- data/lib/{jdbc_adapter/jdbc_derby.rb → arjdbc/derby/adapter.rb} +8 -26
- data/lib/arjdbc/derby/connection_methods.rb +18 -0
- data/lib/arjdbc/discover.rb +99 -0
- data/lib/arjdbc/firebird.rb +2 -0
- data/lib/{jdbc_adapter/jdbc_firebird.rb → arjdbc/firebird/adapter.rb} +12 -16
- data/lib/arjdbc/h2.rb +4 -0
- data/lib/arjdbc/h2/adapter.rb +15 -0
- data/lib/arjdbc/h2/connection_methods.rb +12 -0
- data/lib/arjdbc/hsqldb.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_hsqldb.rb → arjdbc/hsqldb/adapter.rb} +6 -58
- data/lib/arjdbc/hsqldb/connection_methods.rb +14 -0
- data/lib/arjdbc/informix.rb +3 -0
- data/lib/{jdbc_adapter/jdbc_informix.rb → arjdbc/informix/adapter.rb} +6 -19
- data/lib/arjdbc/informix/connection_methods.rb +10 -0
- data/lib/arjdbc/jdbc.rb +2 -0
- data/lib/arjdbc/jdbc/adapter.rb +235 -0
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/callbacks.rb +44 -0
- data/lib/arjdbc/jdbc/column.rb +38 -0
- data/lib/arjdbc/jdbc/compatibility.rb +51 -0
- data/lib/arjdbc/jdbc/connection.rb +97 -0
- data/lib/arjdbc/jdbc/connection_methods.rb +16 -0
- data/lib/arjdbc/jdbc/core_ext.rb +24 -0
- data/lib/arjdbc/jdbc/discover.rb +18 -0
- data/lib/arjdbc/jdbc/driver.rb +44 -0
- data/lib/arjdbc/jdbc/extension.rb +47 -0
- data/lib/arjdbc/jdbc/java.rb +14 -0
- data/lib/{jdbc_adapter → arjdbc/jdbc}/jdbc.rake +0 -0
- data/lib/{jdbc_adapter → arjdbc/jdbc}/missing_functionality_helper.rb +5 -5
- data/lib/arjdbc/jdbc/quoted_primary_key.rb +28 -0
- data/lib/{jdbc_adapter → arjdbc/jdbc}/railtie.rb +1 -1
- data/lib/{jdbc_adapter → arjdbc/jdbc}/rake_tasks.rb +0 -0
- data/lib/arjdbc/jdbc/require_driver.rb +16 -0
- data/lib/arjdbc/jdbc/type_converter.rb +119 -0
- data/lib/arjdbc/mimer.rb +2 -0
- data/lib/{jdbc_adapter/jdbc_mimer.rb → arjdbc/mimer/adapter.rb} +16 -19
- data/lib/arjdbc/mssql.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_mssql.rb → arjdbc/mssql/adapter.rb} +19 -31
- data/lib/arjdbc/mssql/connection_methods.rb +13 -0
- data/lib/{jdbc_adapter → arjdbc/mssql}/tsql_helper.rb +1 -1
- data/lib/arjdbc/mysql.rb +4 -0
- data/lib/arjdbc/mysql/adapter.rb +388 -0
- data/lib/arjdbc/mysql/connection_methods.rb +26 -0
- data/lib/arjdbc/oracle.rb +3 -0
- data/lib/{jdbc_adapter/jdbc_oracle.rb → arjdbc/oracle/adapter.rb} +9 -17
- data/lib/arjdbc/oracle/connection_methods.rb +11 -0
- data/lib/arjdbc/postgresql.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_postgre.rb → arjdbc/postgresql/adapter.rb} +7 -36
- data/lib/arjdbc/postgresql/connection_methods.rb +21 -0
- data/lib/arjdbc/sqlite3.rb +4 -0
- data/lib/{jdbc_adapter/jdbc_sqlite3.rb → arjdbc/sqlite3/adapter.rb} +106 -104
- data/lib/arjdbc/sqlite3/connection_methods.rb +33 -0
- data/lib/arjdbc/sybase.rb +2 -0
- data/lib/arjdbc/sybase/adapter.rb +46 -0
- data/lib/arjdbc/version.rb +8 -0
- data/lib/jdbc_adapter.rb +2 -27
- data/lib/jdbc_adapter/version.rb +3 -5
- data/rails_generators/templates/config/initializers/jdbc.rb +1 -1
- data/rakelib/compile.rake +3 -2
- data/rakelib/package.rake +3 -3
- data/src/java/{jdbc_adapter/JdbcDerbySpec.java → arjdbc/derby/DerbyModule.java} +32 -32
- data/src/java/{jdbc_adapter/JdbcAdapterInternalService.java → arjdbc/jdbc/AdapterJavaService.java} +13 -7
- data/src/java/{jdbc_adapter → arjdbc/jdbc}/JdbcConnectionFactory.java +6 -6
- data/src/java/{jdbc_adapter → arjdbc/jdbc}/RubyJdbcConnection.java +91 -16
- data/src/java/arjdbc/jdbc/SQLBlock.java +48 -0
- data/src/java/{jdbc_adapter → arjdbc/mssql}/MssqlRubyJdbcConnection.java +5 -2
- data/src/java/{jdbc_adapter/JdbcMySQLSpec.java → arjdbc/mysql/MySQLModule.java} +12 -12
- data/src/java/{jdbc_adapter/PostgresRubyJdbcConnection.java → arjdbc/postgresql/PostgresqlRubyJdbcConnection.java} +11 -9
- data/src/java/arjdbc/sqlite3/Sqlite3RubyJdbcConnection.java +64 -0
- data/test/abstract_db_create.rb +4 -1
- data/test/activerecord/connection_adapters/type_conversion_test.rb +1 -1
- data/test/db/cachedb.rb +0 -0
- data/test/db/derby.rb +12 -14
- data/test/db/hsqldb.rb +3 -2
- data/test/db/jndi_config.rb +4 -4
- data/test/db/sqlite3.rb +2 -6
- data/test/db2_simple_test.rb +23 -0
- data/test/derby_migration_test.rb +50 -3
- data/test/jdbc_common.rb +1 -1
- data/test/jndi_callbacks_test.rb +1 -0
- data/test/postgres_nonseq_pkey_test.rb +0 -2
- data/test/postgres_schema_search_path_test.rb +0 -2
- data/test/simple.rb +3 -3
- data/test/sybase_jtds_simple_test.rb +22 -0
- metadata +82 -46
- data/lib/active_record/connection_adapters/jdbc_adapter_spec.rb +0 -26
- data/lib/jdbc_adapter/jdbc_adapter_internal.jar +0 -0
- data/lib/jdbc_adapter/jdbc_cachedb.rb +0 -33
- data/lib/jdbc_adapter/jdbc_mysql.rb +0 -260
- data/lib/jdbc_adapter/jdbc_sybase.rb +0 -50
- data/src/java/jdbc_adapter/SQLBlock.java +0 -27
- data/src/java/jdbc_adapter/Sqlite3RubyJdbcConnection.java +0 -41
- data/test/jdbc_adapter/jdbc_db2_test.rb +0 -26
- data/test/jdbc_adapter/jdbc_sybase_test.rb +0 -33
- data/test/minirunit.rb +0 -109
- data/test/minirunit/testConnect.rb +0 -14
- data/test/minirunit/testH2.rb +0 -73
- data/test/minirunit/testHsqldb.rb +0 -73
- data/test/minirunit/testLoadActiveRecord.rb +0 -3
- data/test/minirunit/testMysql.rb +0 -83
- data/test/minirunit/testRawSelect.rb +0 -24
@@ -1 +1 @@
|
|
1
|
-
require '
|
1
|
+
require 'arjdbc/jdbc'
|
@@ -1,13 +1 @@
|
|
1
|
-
|
2
|
-
begin
|
3
|
-
require "jdbc/jtds"
|
4
|
-
rescue LoadError
|
5
|
-
unless tried_gem
|
6
|
-
require 'rubygems'
|
7
|
-
gem "jdbc-mssql"
|
8
|
-
tried_gem = true
|
9
|
-
retry
|
10
|
-
end
|
11
|
-
# trust that the jtds jar is already present
|
12
|
-
end
|
13
|
-
require 'active_record/connection_adapters/jdbc_adapter'
|
1
|
+
require 'arjdbc/mssql'
|
@@ -1,13 +1 @@
|
|
1
|
-
|
2
|
-
begin
|
3
|
-
require "jdbc/mysql"
|
4
|
-
rescue LoadError
|
5
|
-
unless tried_gem
|
6
|
-
require 'rubygems'
|
7
|
-
gem "jdbc-mysql"
|
8
|
-
tried_gem = true
|
9
|
-
retry
|
10
|
-
end
|
11
|
-
# trust that the mysql jar is already present
|
12
|
-
end
|
13
|
-
require 'active_record/connection_adapters/jdbc_adapter'
|
1
|
+
require 'arjdbc/mysql'
|
@@ -1 +1 @@
|
|
1
|
-
require '
|
1
|
+
require 'arjdbc/oracle'
|
@@ -1,13 +1 @@
|
|
1
|
-
|
2
|
-
begin
|
3
|
-
require "jdbc/postgres"
|
4
|
-
rescue LoadError
|
5
|
-
unless tried_gem
|
6
|
-
require 'rubygems'
|
7
|
-
gem "jdbc-postgres"
|
8
|
-
tried_gem = true
|
9
|
-
retry
|
10
|
-
end
|
11
|
-
# trust that the postgres jar is already present
|
12
|
-
end
|
13
|
-
require 'active_record/connection_adapters/jdbc_adapter'
|
1
|
+
require 'arjdbc/postgresql'
|
@@ -1,13 +1 @@
|
|
1
|
-
|
2
|
-
begin
|
3
|
-
require "jdbc/sqlite3"
|
4
|
-
rescue LoadError
|
5
|
-
unless tried_gem
|
6
|
-
require 'rubygems'
|
7
|
-
gem "jdbc-sqlite3"
|
8
|
-
tried_gem = true
|
9
|
-
retry
|
10
|
-
end
|
11
|
-
# trust that the sqlite jar is already present
|
12
|
-
end
|
13
|
-
require 'active_record/connection_adapters/jdbc_adapter'
|
1
|
+
require 'arjdbc/sqlite3'
|
data/lib/arjdbc.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
if defined?(JRUBY_VERSION)
|
2
|
+
begin
|
3
|
+
tried_gem ||= false
|
4
|
+
require 'active_record/version'
|
5
|
+
rescue LoadError
|
6
|
+
raise if tried_gem
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'activerecord'
|
9
|
+
tried_gem = true
|
10
|
+
retry
|
11
|
+
end
|
12
|
+
if ActiveRecord::VERSION::MAJOR < 2
|
13
|
+
if defined?(RAILS_CONNECTION_ADAPTERS)
|
14
|
+
RAILS_CONNECTION_ADAPTERS << %q(jdbc)
|
15
|
+
else
|
16
|
+
RAILS_CONNECTION_ADAPTERS = %w(jdbc)
|
17
|
+
end
|
18
|
+
if ActiveRecord::VERSION::MAJOR == 1 && ActiveRecord::VERSION::MINOR == 14
|
19
|
+
require 'arjdbc/jdbc'
|
20
|
+
end
|
21
|
+
else
|
22
|
+
require 'active_record'
|
23
|
+
require 'arjdbc/jdbc'
|
24
|
+
end
|
25
|
+
else
|
26
|
+
warn "ActiveRecord-JDBC is for use with JRuby only"
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'arjdbc/version'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'arjdbc/mssql/tsql_helper'
|
2
|
+
|
3
|
+
module ::ArJdbc
|
4
|
+
module CacheDB
|
5
|
+
include TSqlMethods
|
6
|
+
|
7
|
+
def self.column_selector
|
8
|
+
[ /cache/i, lambda { | cfg, col | col.extend( ::ArJdbc::CacheDB::Column ) } ]
|
9
|
+
end
|
10
|
+
|
11
|
+
module Column
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_table(name, options = { })
|
15
|
+
super(name, options)
|
16
|
+
primary_key = options[:primary_key] || "id"
|
17
|
+
execute "ALTER TABLE #{name} ADD CONSTRAINT #{name}_PK PRIMARY KEY(#{primary_key})" unless options[:id] == false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class ActiveRecord::Base
|
2
|
+
class << self
|
3
|
+
def cachedb_connection( config )
|
4
|
+
config[:port] ||= 1972
|
5
|
+
config[:url] ||= "jdbc:Cache://#{config[:host]}:#{config[:port]}/#{ config[:database]}"
|
6
|
+
config[:driver] ||= "com.intersys.jdbc.CacheDriver"
|
7
|
+
jdbc_connection(config)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/lib/arjdbc/db2.rb
ADDED
@@ -1,21 +1,5 @@
|
|
1
|
-
module
|
1
|
+
module ArJdbc
|
2
2
|
module DB2
|
3
|
-
def self.adapter_matcher(name, config)
|
4
|
-
if name =~ /db2/i
|
5
|
-
return config[:url] =~ /^jdbc:derby:net:/ ? ::JdbcSpec::Derby : self
|
6
|
-
end
|
7
|
-
false
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.adapter_selector
|
11
|
-
[/db2/i, lambda {|cfg,adapt|
|
12
|
-
if cfg[:url] =~ /^jdbc:derby:net:/
|
13
|
-
adapt.extend(::JdbcSpec::Derby)
|
14
|
-
else
|
15
|
-
adapt.extend(::JdbcSpec::DB2)
|
16
|
-
end }]
|
17
|
-
end
|
18
|
-
|
19
3
|
def self.extended(obj)
|
20
4
|
# Ignore these 4 system tables
|
21
5
|
ActiveRecord::SchemaDumper.ignore_tables |= %w{hmon_atm_info hmon_collection policy stmg_dbsize_info}
|
data/lib/arjdbc/derby.rb
ADDED
@@ -1,30 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
|
3
|
-
module ::JdbcSpec
|
4
|
-
module ActiveRecordExtensions
|
5
|
-
def derby_connection(config)
|
6
|
-
require File.dirname(__FILE__) + "/../active_record/connection_adapters/derby_adapter"
|
7
|
-
config[:url] ||= "jdbc:derby:#{config[:database]};create=true"
|
8
|
-
config[:driver] ||= "org.apache.derby.jdbc.EmbeddedDriver"
|
9
|
-
check_version(embedded_driver(config))
|
10
|
-
end
|
11
|
-
|
12
|
-
def check_version(conn)
|
13
|
-
md = conn.raw_connection.connection.meta_data
|
14
|
-
if md.database_major_version < 10 || md.database_minor_version < 5
|
15
|
-
raise ::ActiveRecord::ConnectionFailed, "Derby adapter requires Derby 10.5 or later"
|
16
|
-
end
|
17
|
-
conn
|
18
|
-
end
|
19
|
-
end
|
1
|
+
require 'arjdbc/jdbc/missing_functionality_helper'
|
20
2
|
|
3
|
+
module ::ArJdbc
|
21
4
|
module Derby
|
22
|
-
def self.adapter_matcher(name, *)
|
23
|
-
name =~ /derby/i ? self : false
|
24
|
-
end
|
25
|
-
|
26
5
|
def self.column_selector
|
27
|
-
[/derby/i, lambda {|cfg,col| col.extend(::
|
6
|
+
[/derby/i, lambda {|cfg,col| col.extend(::ArJdbc::Derby::Column)}]
|
28
7
|
end
|
29
8
|
|
30
9
|
def self.monkey_rails
|
@@ -76,7 +55,11 @@ module ::JdbcSpec
|
|
76
55
|
'Derby'
|
77
56
|
end
|
78
57
|
|
79
|
-
include
|
58
|
+
include ArJdbc::MissingFunctionalityHelper
|
59
|
+
|
60
|
+
def index_name_length
|
61
|
+
128
|
62
|
+
end
|
80
63
|
|
81
64
|
# Convert the speficied column type to a SQL string. In Derby, :integers cannot specify
|
82
65
|
# a limit.
|
@@ -232,7 +215,6 @@ module ::JdbcSpec
|
|
232
215
|
super
|
233
216
|
end
|
234
217
|
|
235
|
-
|
236
218
|
# I don't think this method is ever called ??? (stepheneb)
|
237
219
|
def create_column(name, refid, colno)
|
238
220
|
stmt = COLUMN_TYPE_STMT % [refid, strip_quotes(name)]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ActiveRecord
|
2
|
+
class Base
|
3
|
+
class << self
|
4
|
+
def derby_connection(config)
|
5
|
+
config[:url] ||= "jdbc:derby:#{config[:database]};create=true"
|
6
|
+
config[:driver] ||= "org.apache.derby.jdbc.EmbeddedDriver"
|
7
|
+
conn = embedded_driver(config)
|
8
|
+
md = conn.raw_connection.connection.meta_data
|
9
|
+
if md.database_major_version < 10 || md.database_minor_version < 5
|
10
|
+
raise ::ActiveRecord::ConnectionFailed, "Derby adapter requires Derby 10.5 or later"
|
11
|
+
end
|
12
|
+
conn
|
13
|
+
end
|
14
|
+
|
15
|
+
alias_method :jdbcderby_connection, :derby_connection
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# arjdbc/discover.rb: Declare ArJdbc.extension modules in this file
|
2
|
+
# that loads a custom module and adapter.
|
3
|
+
|
4
|
+
module ::ArJdbc
|
5
|
+
# Adapters built-in to AR are required up-front so we can override
|
6
|
+
# the native ones
|
7
|
+
require 'arjdbc/mysql'
|
8
|
+
extension :MySQL do |name|
|
9
|
+
name =~ /mysql/i
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'arjdbc/postgresql'
|
13
|
+
extension :PostgreSQL do |name|
|
14
|
+
name =~ /postgre/i
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'arjdbc/sqlite3'
|
18
|
+
extension :SQLite3 do |name|
|
19
|
+
name =~ /sqlite/i
|
20
|
+
end
|
21
|
+
|
22
|
+
# Other adapters are lazy-loaded
|
23
|
+
extension :CacheDB do |name|
|
24
|
+
if name =~ /cache/i
|
25
|
+
require 'arjdbc/cachedb'
|
26
|
+
true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
extension :DB2 do |name, config|
|
31
|
+
if name =~ /db2/i && config[:url] !~ /^jdbc:derby:net:/
|
32
|
+
require 'arjdbc/db2'
|
33
|
+
true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
extension :Derby do |name|
|
38
|
+
if name =~ /derby/i
|
39
|
+
require 'arjdbc/derby'
|
40
|
+
true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
extension :FireBird do |name|
|
45
|
+
if name =~ /firebird/i
|
46
|
+
require 'arjdbc/firebird'
|
47
|
+
true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
extension :H2 do |name|
|
52
|
+
if name =~ /\.h2\./i
|
53
|
+
require 'arjdbc/h2'
|
54
|
+
true
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
extension :HSQLDB do |name|
|
59
|
+
if name =~ /hsqldb/i
|
60
|
+
require 'arjdbc/hsqldb'
|
61
|
+
true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
extension :Informix do |name|
|
66
|
+
if name =~ /informix/i
|
67
|
+
require 'arjdbc/informix'
|
68
|
+
true
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
extension :Mimer do |name|
|
73
|
+
if name =~ /mimer/i
|
74
|
+
require 'arjdbc/mimer'
|
75
|
+
true
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
extension :MsSQL do |name|
|
80
|
+
if name =~ /sqlserver|tds/i
|
81
|
+
require 'arjdbc/mssql'
|
82
|
+
true
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
extension :Oracle do |name|
|
87
|
+
if name =~ /oracle/i
|
88
|
+
require 'arjdbc/oracle'
|
89
|
+
true
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
extension :Sybase do |name|
|
94
|
+
if name =~ /sybase|tds/i
|
95
|
+
require 'arjdbc/sybase'
|
96
|
+
true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -1,16 +1,12 @@
|
|
1
|
-
module ::
|
1
|
+
module ::ArJdbc
|
2
2
|
module FireBird
|
3
|
-
def self.adapter_matcher(name, *)
|
4
|
-
name =~ /firebird/i ? self : false
|
5
|
-
end
|
6
|
-
|
7
3
|
def modify_types(tp)
|
8
4
|
tp[:primary_key] = 'INTEGER NOT NULL PRIMARY KEY'
|
9
5
|
tp[:string][:limit] = 252
|
10
6
|
tp[:integer][:limit] = nil
|
11
7
|
tp
|
12
8
|
end
|
13
|
-
|
9
|
+
|
14
10
|
def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) # :nodoc:
|
15
11
|
execute(sql, name)
|
16
12
|
id_value
|
@@ -31,11 +27,11 @@ module ::JdbcSpec
|
|
31
27
|
def default_sequence_name(table_name, primary_key) # :nodoc:
|
32
28
|
"#{table_name}_seq"
|
33
29
|
end
|
34
|
-
|
30
|
+
|
35
31
|
def next_sequence_value(sequence_name)
|
36
32
|
select_one("SELECT GEN_ID(#{sequence_name}, 1 ) FROM RDB$DATABASE;")["gen_id"]
|
37
33
|
end
|
38
|
-
|
34
|
+
|
39
35
|
def create_table(name, options = {}) #:nodoc:
|
40
36
|
super(name, options)
|
41
37
|
execute "CREATE GENERATOR #{name}_seq"
|
@@ -44,7 +40,7 @@ module ::JdbcSpec
|
|
44
40
|
def rename_table(name, new_name) #:nodoc:
|
45
41
|
execute "RENAME #{name} TO #{new_name}"
|
46
42
|
execute "UPDATE RDB$GENERATORS SET RDB$GENERATOR_NAME='#{new_name}_seq' WHERE RDB$GENERATOR_NAME='#{name}_seq'" rescue nil
|
47
|
-
end
|
43
|
+
end
|
48
44
|
|
49
45
|
def drop_table(name, options = {}) #:nodoc:
|
50
46
|
super(name)
|
@@ -62,10 +58,10 @@ module ::JdbcSpec
|
|
62
58
|
def remove_index(table_name, options) #:nodoc:
|
63
59
|
execute "DROP INDEX #{index_name(table_name, options)}"
|
64
60
|
end
|
65
|
-
|
61
|
+
|
66
62
|
def quote(value, column = nil) # :nodoc:
|
67
63
|
return value.quoted_id if value.respond_to?(:quoted_id)
|
68
|
-
|
64
|
+
|
69
65
|
if [Time, DateTime].include?(value.class)
|
70
66
|
"CAST('#{value.strftime("%Y-%m-%d %H:%M:%S")}' AS TIMESTAMP)"
|
71
67
|
else
|
@@ -79,27 +75,27 @@ module ::JdbcSpec
|
|
79
75
|
def quote_string(string) # :nodoc:
|
80
76
|
string.gsub(/'/, "''")
|
81
77
|
end
|
82
|
-
|
78
|
+
|
83
79
|
def quote_column_name(column_name) # :nodoc:
|
84
80
|
%Q("#{ar_to_fb_case(column_name)}")
|
85
81
|
end
|
86
|
-
|
82
|
+
|
87
83
|
def quoted_true # :nodoc:
|
88
84
|
quote(1)
|
89
85
|
end
|
90
|
-
|
86
|
+
|
91
87
|
def quoted_false # :nodoc:
|
92
88
|
quote(0)
|
93
89
|
end
|
94
90
|
|
95
91
|
private
|
96
|
-
|
92
|
+
|
97
93
|
# Maps uppercase Firebird column names to lowercase for ActiveRecord;
|
98
94
|
# mixed-case columns retain their original case.
|
99
95
|
def fb_to_ar_case(column_name)
|
100
96
|
column_name =~ /[[:lower:]]/ ? column_name : column_name.to_s.downcase
|
101
97
|
end
|
102
|
-
|
98
|
+
|
103
99
|
# Maps lowercase ActiveRecord column names to uppercase for Fierbird;
|
104
100
|
# mixed-case columns retain their original case.
|
105
101
|
def ar_to_fb_case(column_name)
|