activerecord-jdbc-alt-adapter 50.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/.travis.yml +100 -0
- data/.yardopts +4 -0
- data/CONTRIBUTING.md +50 -0
- data/Gemfile +92 -0
- data/History.md +1191 -0
- data/LICENSE.txt +26 -0
- data/README.md +240 -0
- data/RUNNING_TESTS.md +127 -0
- data/Rakefile +336 -0
- data/Rakefile.jdbc +20 -0
- data/activerecord-jdbc-adapter.gemspec +55 -0
- data/activerecord-jdbc-alt-adapter.gemspec +56 -0
- data/lib/active_record/connection_adapters/as400_adapter.rb +2 -0
- data/lib/active_record/connection_adapters/db2_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/derby_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/firebird_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/h2_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/hsqldb_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/informix_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/jdbc_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/jndi_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mariadb_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mssql_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mysql2_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/mysql_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/postgresql_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/sqlite3_adapter.rb +1 -0
- data/lib/active_record/connection_adapters/sqlserver_adapter.rb +1 -0
- data/lib/activerecord-jdbc-adapter.rb +1 -0
- data/lib/arel/visitors/compat.rb +60 -0
- data/lib/arel/visitors/db2.rb +137 -0
- data/lib/arel/visitors/derby.rb +112 -0
- data/lib/arel/visitors/firebird.rb +79 -0
- data/lib/arel/visitors/h2.rb +25 -0
- data/lib/arel/visitors/hsqldb.rb +32 -0
- data/lib/arel/visitors/postgresql_jdbc.rb +6 -0
- data/lib/arel/visitors/sql_server.rb +225 -0
- data/lib/arel/visitors/sql_server/ng42.rb +294 -0
- data/lib/arel/visitors/sqlserver.rb +214 -0
- data/lib/arjdbc.rb +19 -0
- data/lib/arjdbc/abstract/connection_management.rb +35 -0
- data/lib/arjdbc/abstract/core.rb +74 -0
- data/lib/arjdbc/abstract/database_statements.rb +64 -0
- data/lib/arjdbc/abstract/statement_cache.rb +58 -0
- data/lib/arjdbc/abstract/transaction_support.rb +86 -0
- data/lib/arjdbc/db2.rb +4 -0
- data/lib/arjdbc/db2/adapter.rb +789 -0
- data/lib/arjdbc/db2/as400.rb +130 -0
- data/lib/arjdbc/db2/column.rb +167 -0
- data/lib/arjdbc/db2/connection_methods.rb +44 -0
- data/lib/arjdbc/derby.rb +3 -0
- data/lib/arjdbc/derby/active_record_patch.rb +13 -0
- data/lib/arjdbc/derby/adapter.rb +540 -0
- data/lib/arjdbc/derby/connection_methods.rb +20 -0
- data/lib/arjdbc/derby/schema_creation.rb +15 -0
- data/lib/arjdbc/discover.rb +104 -0
- data/lib/arjdbc/firebird.rb +4 -0
- data/lib/arjdbc/firebird/adapter.rb +434 -0
- data/lib/arjdbc/firebird/connection_methods.rb +23 -0
- data/lib/arjdbc/h2.rb +3 -0
- data/lib/arjdbc/h2/adapter.rb +303 -0
- data/lib/arjdbc/h2/connection_methods.rb +27 -0
- data/lib/arjdbc/hsqldb.rb +3 -0
- data/lib/arjdbc/hsqldb/adapter.rb +297 -0
- data/lib/arjdbc/hsqldb/connection_methods.rb +28 -0
- data/lib/arjdbc/hsqldb/explain_support.rb +35 -0
- data/lib/arjdbc/hsqldb/schema_creation.rb +11 -0
- data/lib/arjdbc/informix.rb +5 -0
- data/lib/arjdbc/informix/adapter.rb +162 -0
- data/lib/arjdbc/informix/connection_methods.rb +9 -0
- data/lib/arjdbc/jdbc.rb +59 -0
- data/lib/arjdbc/jdbc/adapter.rb +475 -0
- data/lib/arjdbc/jdbc/adapter_require.rb +46 -0
- data/lib/arjdbc/jdbc/base_ext.rb +15 -0
- data/lib/arjdbc/jdbc/callbacks.rb +53 -0
- data/lib/arjdbc/jdbc/column.rb +97 -0
- data/lib/arjdbc/jdbc/connection.rb +14 -0
- data/lib/arjdbc/jdbc/connection_methods.rb +37 -0
- data/lib/arjdbc/jdbc/error.rb +65 -0
- data/lib/arjdbc/jdbc/extension.rb +59 -0
- data/lib/arjdbc/jdbc/java.rb +13 -0
- data/lib/arjdbc/jdbc/railtie.rb +2 -0
- data/lib/arjdbc/jdbc/rake_tasks.rb +3 -0
- data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -0
- data/lib/arjdbc/jdbc/type_cast.rb +166 -0
- data/lib/arjdbc/jdbc/type_converter.rb +142 -0
- data/lib/arjdbc/mssql.rb +7 -0
- data/lib/arjdbc/mssql/adapter.rb +384 -0
- data/lib/arjdbc/mssql/column.rb +29 -0
- data/lib/arjdbc/mssql/connection_methods.rb +79 -0
- data/lib/arjdbc/mssql/database_statements.rb +134 -0
- data/lib/arjdbc/mssql/errors.rb +6 -0
- data/lib/arjdbc/mssql/explain_support.rb +129 -0
- data/lib/arjdbc/mssql/extensions.rb +36 -0
- data/lib/arjdbc/mssql/limit_helpers.rb +231 -0
- data/lib/arjdbc/mssql/lock_methods.rb +77 -0
- data/lib/arjdbc/mssql/old_adapter.rb +804 -0
- data/lib/arjdbc/mssql/old_column.rb +200 -0
- data/lib/arjdbc/mssql/quoting.rb +101 -0
- data/lib/arjdbc/mssql/schema_creation.rb +31 -0
- data/lib/arjdbc/mssql/schema_definitions.rb +74 -0
- data/lib/arjdbc/mssql/schema_statements.rb +329 -0
- data/lib/arjdbc/mssql/transaction.rb +69 -0
- data/lib/arjdbc/mssql/types.rb +52 -0
- data/lib/arjdbc/mssql/types/binary_types.rb +33 -0
- data/lib/arjdbc/mssql/types/date_and_time_types.rb +134 -0
- data/lib/arjdbc/mssql/types/deprecated_types.rb +40 -0
- data/lib/arjdbc/mssql/types/numeric_types.rb +71 -0
- data/lib/arjdbc/mssql/types/string_types.rb +56 -0
- data/lib/arjdbc/mssql/utils.rb +66 -0
- data/lib/arjdbc/mysql.rb +3 -0
- data/lib/arjdbc/mysql/adapter.rb +140 -0
- data/lib/arjdbc/mysql/connection_methods.rb +166 -0
- data/lib/arjdbc/oracle/adapter.rb +863 -0
- data/lib/arjdbc/postgresql.rb +3 -0
- data/lib/arjdbc/postgresql/adapter.rb +687 -0
- data/lib/arjdbc/postgresql/base/array_decoder.rb +26 -0
- data/lib/arjdbc/postgresql/base/array_encoder.rb +25 -0
- data/lib/arjdbc/postgresql/base/array_parser.rb +95 -0
- data/lib/arjdbc/postgresql/base/pgconn.rb +11 -0
- data/lib/arjdbc/postgresql/column.rb +51 -0
- data/lib/arjdbc/postgresql/connection_methods.rb +67 -0
- data/lib/arjdbc/postgresql/name.rb +24 -0
- data/lib/arjdbc/postgresql/oid_types.rb +266 -0
- data/lib/arjdbc/railtie.rb +11 -0
- data/lib/arjdbc/sqlite3.rb +3 -0
- data/lib/arjdbc/sqlite3/adapter.rb +678 -0
- data/lib/arjdbc/sqlite3/connection_methods.rb +59 -0
- data/lib/arjdbc/sybase.rb +2 -0
- data/lib/arjdbc/sybase/adapter.rb +47 -0
- data/lib/arjdbc/tasks.rb +13 -0
- data/lib/arjdbc/tasks/database_tasks.rb +31 -0
- data/lib/arjdbc/tasks/databases.rake +48 -0
- data/lib/arjdbc/tasks/db2_database_tasks.rb +104 -0
- data/lib/arjdbc/tasks/derby_database_tasks.rb +95 -0
- data/lib/arjdbc/tasks/h2_database_tasks.rb +31 -0
- data/lib/arjdbc/tasks/hsqldb_database_tasks.rb +70 -0
- data/lib/arjdbc/tasks/jdbc_database_tasks.rb +169 -0
- data/lib/arjdbc/tasks/mssql_database_tasks.rb +46 -0
- data/lib/arjdbc/util/quoted_cache.rb +60 -0
- data/lib/arjdbc/util/serialized_attributes.rb +98 -0
- data/lib/arjdbc/util/table_copier.rb +110 -0
- data/lib/arjdbc/version.rb +3 -0
- data/lib/generators/jdbc/USAGE +9 -0
- data/lib/generators/jdbc/jdbc_generator.rb +17 -0
- data/lib/jdbc_adapter.rb +2 -0
- data/lib/jdbc_adapter/rake_tasks.rb +4 -0
- data/lib/jdbc_adapter/version.rb +4 -0
- data/pom.xml +114 -0
- data/rails_generators/jdbc_generator.rb +15 -0
- data/rails_generators/templates/config/initializers/jdbc.rb +10 -0
- data/rails_generators/templates/lib/tasks/jdbc.rake +11 -0
- data/rakelib/01-tomcat.rake +51 -0
- data/rakelib/02-test.rake +132 -0
- data/rakelib/bundler_ext.rb +11 -0
- data/rakelib/db.rake +75 -0
- data/rakelib/rails.rake +223 -0
- data/src/java/arjdbc/ArJdbcModule.java +276 -0
- data/src/java/arjdbc/db2/DB2Module.java +76 -0
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +126 -0
- data/src/java/arjdbc/derby/DerbyModule.java +178 -0
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +152 -0
- data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +174 -0
- data/src/java/arjdbc/h2/H2Module.java +50 -0
- data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +85 -0
- data/src/java/arjdbc/hsqldb/HSQLDBModule.java +73 -0
- data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +75 -0
- data/src/java/arjdbc/jdbc/AdapterJavaService.java +43 -0
- data/src/java/arjdbc/jdbc/Callable.java +44 -0
- data/src/java/arjdbc/jdbc/ConnectionFactory.java +45 -0
- data/src/java/arjdbc/jdbc/DataSourceConnectionFactory.java +156 -0
- data/src/java/arjdbc/jdbc/DriverConnectionFactory.java +63 -0
- data/src/java/arjdbc/jdbc/DriverWrapper.java +119 -0
- data/src/java/arjdbc/jdbc/JdbcResult.java +130 -0
- data/src/java/arjdbc/jdbc/RubyConnectionFactory.java +61 -0
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +3979 -0
- data/src/java/arjdbc/mssql/MSSQLModule.java +90 -0
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +508 -0
- data/src/java/arjdbc/mysql/MySQLModule.java +152 -0
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +294 -0
- data/src/java/arjdbc/oracle/OracleModule.java +80 -0
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +455 -0
- data/src/java/arjdbc/postgresql/ByteaUtils.java +157 -0
- data/src/java/arjdbc/postgresql/PgDateTimeUtils.java +52 -0
- data/src/java/arjdbc/postgresql/PostgreSQLModule.java +77 -0
- data/src/java/arjdbc/postgresql/PostgreSQLResult.java +192 -0
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +948 -0
- data/src/java/arjdbc/sqlite3/SQLite3Module.java +73 -0
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +525 -0
- data/src/java/arjdbc/util/CallResultSet.java +826 -0
- data/src/java/arjdbc/util/DateTimeUtils.java +699 -0
- data/src/java/arjdbc/util/ObjectSupport.java +65 -0
- data/src/java/arjdbc/util/QuotingUtils.java +137 -0
- data/src/java/arjdbc/util/StringCache.java +63 -0
- data/src/java/arjdbc/util/StringHelper.java +145 -0
- metadata +269 -0
@@ -0,0 +1,174 @@
|
|
1
|
+
/*
|
2
|
+
* The MIT License
|
3
|
+
*
|
4
|
+
* Copyright 2015 Karol Bucek.
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
11
|
+
* furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included in
|
14
|
+
* all copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
* THE SOFTWARE.
|
23
|
+
*/
|
24
|
+
package arjdbc.firebird;
|
25
|
+
|
26
|
+
import arjdbc.jdbc.RubyJdbcConnection;
|
27
|
+
|
28
|
+
import java.sql.Connection;
|
29
|
+
import java.sql.ResultSet;
|
30
|
+
import java.sql.SQLException;
|
31
|
+
import java.sql.PreparedStatement;
|
32
|
+
import java.sql.ResultSetMetaData;
|
33
|
+
import java.sql.Types;
|
34
|
+
|
35
|
+
import org.jruby.Ruby;
|
36
|
+
import org.jruby.RubyClass;
|
37
|
+
import org.jruby.RubyString;
|
38
|
+
import org.jruby.runtime.ObjectAllocator;
|
39
|
+
import org.jruby.runtime.ThreadContext;
|
40
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
41
|
+
|
42
|
+
/**
|
43
|
+
* @author kares
|
44
|
+
*/
|
45
|
+
public class FirebirdRubyJdbcConnection extends RubyJdbcConnection {
|
46
|
+
|
47
|
+
protected FirebirdRubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
|
48
|
+
super(runtime, metaClass);
|
49
|
+
}
|
50
|
+
|
51
|
+
public static RubyClass createFirebirdJdbcConnectionClass(Ruby runtime, RubyClass jdbcConnection) {
|
52
|
+
final RubyClass clazz = RubyJdbcConnection.getConnectionAdapters(runtime).
|
53
|
+
defineClassUnder("FirebirdJdbcConnection", jdbcConnection, ALLOCATOR);
|
54
|
+
clazz.defineAnnotatedMethods(FirebirdRubyJdbcConnection.class);
|
55
|
+
return clazz;
|
56
|
+
}
|
57
|
+
|
58
|
+
private static final ObjectAllocator ALLOCATOR = new ObjectAllocator() {
|
59
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
60
|
+
return new FirebirdRubyJdbcConnection(runtime, klass);
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
@Override // resultSet.wasNull() might be falsy for '' treated as null
|
65
|
+
protected IRubyObject stringToRuby(final ThreadContext context,
|
66
|
+
final Ruby runtime, final ResultSet resultSet, final int column)
|
67
|
+
throws SQLException {
|
68
|
+
final String value = resultSet.getString(column);
|
69
|
+
if ( value == null ) return runtime.getNil();
|
70
|
+
return RubyString.newUnicodeString(runtime, value);
|
71
|
+
}
|
72
|
+
|
73
|
+
@Override // booleans are emulated can not setNull(index, Types.BOOLEAN)
|
74
|
+
protected void setBooleanParameter(final ThreadContext context,
|
75
|
+
final Connection connection, final PreparedStatement statement,
|
76
|
+
final int index, final IRubyObject value,
|
77
|
+
final IRubyObject attribute, final int type) throws SQLException {
|
78
|
+
if ( value.isNil() ) statement.setNull(index, Types.CHAR);
|
79
|
+
else {
|
80
|
+
statement.setBoolean(index, value.isTrue());
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
protected IRubyObject jdbcToRuby(
|
85
|
+
final ThreadContext context, final Ruby runtime,
|
86
|
+
final int column, final int type, final ResultSet resultSet)
|
87
|
+
throws SQLException {
|
88
|
+
|
89
|
+
switch (type) {
|
90
|
+
case SMALL_CHAR_1:
|
91
|
+
return smallChar1ToRuby(runtime, resultSet, column);
|
92
|
+
case SMALL_CHAR_2:
|
93
|
+
return smallChar2ToRuby(runtime, resultSet, column);
|
94
|
+
}
|
95
|
+
return super.jdbcToRuby(context, runtime, column, type, resultSet);
|
96
|
+
}
|
97
|
+
|
98
|
+
private static IRubyObject smallChar1ToRuby(
|
99
|
+
final Ruby runtime, final ResultSet resultSet, final int column)
|
100
|
+
throws SQLException {
|
101
|
+
String value = resultSet.getString(column);
|
102
|
+
if ( value == null ) return runtime.getNil();
|
103
|
+
if ( value.length() > 1 && value.charAt(1) == ' ' ) {
|
104
|
+
value = value.substring(0, 1);
|
105
|
+
}
|
106
|
+
return RubyString.newUnicodeString(runtime, value);
|
107
|
+
}
|
108
|
+
|
109
|
+
private static IRubyObject smallChar2ToRuby(
|
110
|
+
final Ruby runtime, final ResultSet resultSet, final int column)
|
111
|
+
throws SQLException {
|
112
|
+
String value = resultSet.getString(column);
|
113
|
+
if ( value == null ) return runtime.getNil();
|
114
|
+
if ( value.length() > 2 && value.charAt(2) == ' ' ) {
|
115
|
+
value = value.substring(0, 2);
|
116
|
+
}
|
117
|
+
return RubyString.newUnicodeString(runtime, value);
|
118
|
+
}
|
119
|
+
|
120
|
+
private final static int SMALL_CHAR_1 = 31431001;
|
121
|
+
private final static int SMALL_CHAR_2 = 31431002;
|
122
|
+
|
123
|
+
@Override
|
124
|
+
protected ColumnData[] extractColumns(final ThreadContext context,
|
125
|
+
final Connection connection, final ResultSet resultSet,
|
126
|
+
final boolean downCase) throws SQLException {
|
127
|
+
|
128
|
+
final ResultSetMetaData resultMetaData = resultSet.getMetaData();
|
129
|
+
|
130
|
+
final int columnCount = resultMetaData.getColumnCount();
|
131
|
+
final ColumnData[] columns = new ColumnData[columnCount];
|
132
|
+
|
133
|
+
for ( int i = 1; i <= columnCount; i++ ) { // metadata is one-based
|
134
|
+
String name = resultMetaData.getColumnLabel(i);
|
135
|
+
if ( downCase ) {
|
136
|
+
name = name.toLowerCase();
|
137
|
+
} else {
|
138
|
+
name = caseConvertIdentifierForRails(connection, name);
|
139
|
+
}
|
140
|
+
final RubyString columnName = RubyString.newUnicodeString(context.runtime, name);
|
141
|
+
|
142
|
+
int columnType = resultMetaData.getColumnType(i);
|
143
|
+
if (columnType == Types.CHAR) {
|
144
|
+
// CHAR(1) 'aligned' by JayBird to "1 "
|
145
|
+
final int prec = resultMetaData.getPrecision(i);
|
146
|
+
if ( prec == 1 ) {
|
147
|
+
columnType = SMALL_CHAR_1;
|
148
|
+
}
|
149
|
+
else if ( prec == 2 ) {
|
150
|
+
columnType = SMALL_CHAR_2;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
columns[i - 1] = new ColumnData(columnName, columnType, i);
|
155
|
+
}
|
156
|
+
|
157
|
+
return columns;
|
158
|
+
}
|
159
|
+
|
160
|
+
// storesMixedCaseIdentifiers() return false;
|
161
|
+
// storesLowerCaseIdentifiers() return false;
|
162
|
+
// storesUpperCaseIdentifiers() return true;
|
163
|
+
|
164
|
+
@Override
|
165
|
+
protected String caseConvertIdentifierForRails(final Connection connection, final String value) {
|
166
|
+
return value == null ? null : value.toLowerCase();
|
167
|
+
}
|
168
|
+
|
169
|
+
@Override
|
170
|
+
protected String caseConvertIdentifierForJdbc(final Connection connection, final String value) {
|
171
|
+
return value == null ? null : value.toUpperCase();
|
172
|
+
}
|
173
|
+
|
174
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Copyright (c) 2012-2013 Karol Bucek <self@kares.org>
|
3
|
+
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
4
|
+
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
* a copy of this software and associated documentation files (the
|
8
|
+
* "Software"), to deal in the Software without restriction, including
|
9
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
* the following conditions:
|
13
|
+
*
|
14
|
+
* The above copyright notice and this permission notice shall be
|
15
|
+
* included in all copies or substantial portions of the Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
***** END LICENSE BLOCK *****/
|
25
|
+
|
26
|
+
package arjdbc.h2;
|
27
|
+
|
28
|
+
import org.jruby.Ruby;
|
29
|
+
import org.jruby.RubyModule;
|
30
|
+
|
31
|
+
/**
|
32
|
+
* ArJdbc::H2
|
33
|
+
*
|
34
|
+
* @author kares
|
35
|
+
*/
|
36
|
+
//@org.jruby.anno.JRubyModule(name = "ArJdbc::H2")
|
37
|
+
public class H2Module {
|
38
|
+
|
39
|
+
public static RubyModule load(final RubyModule arJdbc) {
|
40
|
+
RubyModule h2 = arJdbc.defineModuleUnder("H2");
|
41
|
+
// NOTE: currently no Java implemented Ruby methods
|
42
|
+
// h2.defineAnnotatedMethods( H2Module.class );
|
43
|
+
return h2;
|
44
|
+
}
|
45
|
+
|
46
|
+
public static RubyModule load(final Ruby runtime) {
|
47
|
+
return load( arjdbc.ArJdbcModule.get(runtime) );
|
48
|
+
}
|
49
|
+
|
50
|
+
}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
3
|
+
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
4
|
+
* Copyright (c) 2008-2009 Thomas E Enebo <enebo@acm.org>
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
* a copy of this software and associated documentation files (the
|
8
|
+
* "Software"), to deal in the Software without restriction, including
|
9
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
* the following conditions:
|
13
|
+
*
|
14
|
+
* The above copyright notice and this permission notice shall be
|
15
|
+
* included in all copies or substantial portions of the Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
***** END LICENSE BLOCK *****/
|
25
|
+
|
26
|
+
package arjdbc.h2;
|
27
|
+
|
28
|
+
import java.sql.Connection;
|
29
|
+
import java.sql.SQLException;
|
30
|
+
|
31
|
+
import org.jruby.Ruby;
|
32
|
+
import org.jruby.RubyClass;
|
33
|
+
import org.jruby.runtime.ObjectAllocator;
|
34
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
35
|
+
|
36
|
+
/**
|
37
|
+
*
|
38
|
+
* @author nicksieger
|
39
|
+
*/
|
40
|
+
@org.jruby.anno.JRubyClass(name = "ActiveRecord::ConnectionAdapters::H2JdbcConnection")
|
41
|
+
public class H2RubyJdbcConnection extends arjdbc.jdbc.RubyJdbcConnection {
|
42
|
+
private static final long serialVersionUID = -2652911264521657428L;
|
43
|
+
|
44
|
+
public H2RubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
|
45
|
+
super(runtime, metaClass);
|
46
|
+
}
|
47
|
+
|
48
|
+
public static RubyClass createH2JdbcConnectionClass(Ruby runtime, RubyClass jdbcConnection) {
|
49
|
+
RubyClass clazz = getConnectionAdapters(runtime).
|
50
|
+
defineClassUnder("H2JdbcConnection", jdbcConnection, ALLOCATOR);
|
51
|
+
clazz.defineAnnotatedMethods(H2RubyJdbcConnection.class);
|
52
|
+
return clazz;
|
53
|
+
}
|
54
|
+
|
55
|
+
public static RubyClass load(final Ruby runtime) {
|
56
|
+
RubyClass jdbcConnection = getJdbcConnection(runtime);
|
57
|
+
return createH2JdbcConnectionClass(runtime, jdbcConnection);
|
58
|
+
}
|
59
|
+
|
60
|
+
protected static ObjectAllocator ALLOCATOR = new ObjectAllocator() {
|
61
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
62
|
+
return new H2RubyJdbcConnection(runtime, klass);
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
/**
|
67
|
+
* H2 supports schemas.
|
68
|
+
*/
|
69
|
+
@Override
|
70
|
+
protected boolean databaseSupportsSchemas() {
|
71
|
+
return true;
|
72
|
+
}
|
73
|
+
|
74
|
+
@Override
|
75
|
+
protected String caseConvertIdentifierForJdbc(final Connection connection, final String value) {
|
76
|
+
if ( value == null ) return null;
|
77
|
+
return value.toUpperCase();
|
78
|
+
}
|
79
|
+
|
80
|
+
// NOTE: not supported
|
81
|
+
// org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non-hex character: "PUBLIC" [90004-178]
|
82
|
+
//@Override
|
83
|
+
//protected boolean useByteStrings() { return false; }
|
84
|
+
|
85
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Copyright (c) 2012-2013 Karol Bucek <self@kares.org>
|
3
|
+
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
4
|
+
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
* a copy of this software and associated documentation files (the
|
8
|
+
* "Software"), to deal in the Software without restriction, including
|
9
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
* the following conditions:
|
13
|
+
*
|
14
|
+
* The above copyright notice and this permission notice shall be
|
15
|
+
* included in all copies or substantial portions of the Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
***** END LICENSE BLOCK *****/
|
25
|
+
|
26
|
+
package arjdbc.hsqldb;
|
27
|
+
|
28
|
+
import static arjdbc.util.QuotingUtils.BYTES_0;
|
29
|
+
import static arjdbc.util.QuotingUtils.BYTES_1;
|
30
|
+
import static arjdbc.util.QuotingUtils.quoteSingleQuotesWithFallback;
|
31
|
+
|
32
|
+
import org.jruby.Ruby;
|
33
|
+
import org.jruby.RubyModule;
|
34
|
+
import org.jruby.RubyString;
|
35
|
+
import org.jruby.anno.JRubyMethod;
|
36
|
+
import org.jruby.runtime.ThreadContext;
|
37
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
38
|
+
|
39
|
+
public class HSQLDBModule {
|
40
|
+
|
41
|
+
public static RubyModule load(final RubyModule arJdbc) {
|
42
|
+
RubyModule hsqldb = arJdbc.defineModuleUnder("HSQLDB");
|
43
|
+
hsqldb.defineAnnotatedMethods( HSQLDBModule.class );
|
44
|
+
return hsqldb;
|
45
|
+
}
|
46
|
+
|
47
|
+
public static RubyModule load(final Ruby runtime) {
|
48
|
+
return load( arjdbc.ArJdbcModule.get(runtime) );
|
49
|
+
}
|
50
|
+
|
51
|
+
@JRubyMethod(name = "quote_string", required = 1, frame = false)
|
52
|
+
public static IRubyObject quote_string(
|
53
|
+
final ThreadContext context,
|
54
|
+
final IRubyObject self,
|
55
|
+
final IRubyObject string) {
|
56
|
+
return quoteSingleQuotesWithFallback(context, string);
|
57
|
+
}
|
58
|
+
|
59
|
+
@JRubyMethod(name = "quoted_true", required = 0, frame = false)
|
60
|
+
public static IRubyObject quoted_true(
|
61
|
+
final ThreadContext context,
|
62
|
+
final IRubyObject self) {
|
63
|
+
return RubyString.newString(context.getRuntime(), BYTES_1);
|
64
|
+
}
|
65
|
+
|
66
|
+
@JRubyMethod(name = "quoted_false", required = 0, frame = false)
|
67
|
+
public static IRubyObject quoted_false(
|
68
|
+
final ThreadContext context,
|
69
|
+
final IRubyObject self) {
|
70
|
+
return RubyString.newString(context.getRuntime(), BYTES_0);
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/*
|
2
|
+
**** BEGIN LICENSE BLOCK *****
|
3
|
+
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
4
|
+
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
5
|
+
* Copyright (c) 2008-2009 Thomas E Enebo <enebo@acm.org>
|
6
|
+
*
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
* a copy of this software and associated documentation files (the
|
9
|
+
* "Software"), to deal in the Software without restriction, including
|
10
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
* the following conditions:
|
14
|
+
*
|
15
|
+
* The above copyright notice and this permission notice shall be
|
16
|
+
* included in all copies or substantial portions of the Software.
|
17
|
+
*
|
18
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
***** END LICENSE BLOCK *****/
|
26
|
+
|
27
|
+
package arjdbc.informix;
|
28
|
+
|
29
|
+
import java.sql.ResultSet;
|
30
|
+
import java.sql.SQLException;
|
31
|
+
import java.sql.Types;
|
32
|
+
|
33
|
+
import arjdbc.jdbc.RubyJdbcConnection;
|
34
|
+
|
35
|
+
import org.jruby.Ruby;
|
36
|
+
import org.jruby.RubyClass;
|
37
|
+
import org.jruby.runtime.ObjectAllocator;
|
38
|
+
import org.jruby.runtime.ThreadContext;
|
39
|
+
import org.jruby.runtime.builtin.IRubyObject;
|
40
|
+
|
41
|
+
/**
|
42
|
+
*
|
43
|
+
* @author nicksieger
|
44
|
+
*/
|
45
|
+
public class InformixRubyJdbcConnection extends RubyJdbcConnection {
|
46
|
+
protected InformixRubyJdbcConnection(Ruby runtime, RubyClass metaClass) {
|
47
|
+
super(runtime, metaClass);
|
48
|
+
}
|
49
|
+
|
50
|
+
public static RubyClass createInformixJdbcConnectionClass(Ruby runtime, RubyClass jdbcConnection) {
|
51
|
+
RubyClass clazz = RubyJdbcConnection.getConnectionAdapters(runtime).defineClassUnder("InformixJdbcConnection",
|
52
|
+
jdbcConnection, INFORMIX_JDBCCONNECTION_ALLOCATOR);
|
53
|
+
clazz.defineAnnotatedMethods(InformixRubyJdbcConnection.class);
|
54
|
+
|
55
|
+
return clazz;
|
56
|
+
}
|
57
|
+
|
58
|
+
private static ObjectAllocator INFORMIX_JDBCCONNECTION_ALLOCATOR = new ObjectAllocator() {
|
59
|
+
public IRubyObject allocate(Ruby runtime, RubyClass klass) {
|
60
|
+
return new InformixRubyJdbcConnection(runtime, klass);
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
/**
|
65
|
+
* Treat LONGVARCHAR as CLOB on Informix for purposes of converting a JDBC value to Ruby.
|
66
|
+
*/
|
67
|
+
@Override
|
68
|
+
protected IRubyObject jdbcToRuby(
|
69
|
+
final ThreadContext context, final Ruby runtime,
|
70
|
+
final int column, int type, final ResultSet resultSet)
|
71
|
+
throws SQLException {
|
72
|
+
if ( type == Types.LONGVARCHAR ) type = Types.CLOB;
|
73
|
+
return super.jdbcToRuby(context, runtime, column, type, resultSet);
|
74
|
+
}
|
75
|
+
}
|