activerecord-jdbc-adapter 70.0.pre-java → 70.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/activerecord-jdbc-adapter.gemspec +1 -3
- data/lib/arel/visitors/compat.rb +5 -33
- data/lib/arel/visitors/h2.rb +1 -13
- data/lib/arel/visitors/hsqldb.rb +1 -21
- data/lib/arel/visitors/sql_server.rb +2 -103
- data/lib/arjdbc/abstract/core.rb +8 -9
- data/lib/arjdbc/abstract/database_statements.rb +8 -0
- data/lib/arjdbc/discover.rb +0 -67
- data/lib/arjdbc/jdbc/adapter.rb +1 -1
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/column.rb +1 -26
- data/lib/arjdbc/jdbc.rb +0 -7
- data/lib/arjdbc/mysql/adapter.rb +2 -1
- data/lib/arjdbc/oracle/adapter.rb +4 -23
- data/lib/arjdbc/postgresql/adapter.rb +152 -3
- data/lib/arjdbc/postgresql/oid_types.rb +155 -108
- data/lib/arjdbc/sqlite3/adapter.rb +54 -36
- data/lib/arjdbc/tasks/database_tasks.rb +0 -15
- data/lib/arjdbc/util/serialized_attributes.rb +0 -22
- data/lib/arjdbc/util/table_copier.rb +2 -1
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/02-test.rake +3 -18
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +5 -0
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +5 -0
- metadata +5 -38
- data/lib/active_record/connection_adapters/as400_adapter.rb +0 -2
- data/lib/active_record/connection_adapters/db2_adapter.rb +0 -1
- data/lib/active_record/connection_adapters/derby_adapter.rb +0 -1
- data/lib/active_record/connection_adapters/informix_adapter.rb +0 -1
- data/lib/arel/visitors/db2.rb +0 -137
- data/lib/arel/visitors/derby.rb +0 -112
- data/lib/arel/visitors/firebird.rb +0 -79
- data/lib/arjdbc/db2/adapter.rb +0 -808
- data/lib/arjdbc/db2/as400.rb +0 -142
- data/lib/arjdbc/db2/column.rb +0 -131
- data/lib/arjdbc/db2/connection_methods.rb +0 -48
- data/lib/arjdbc/db2.rb +0 -4
- data/lib/arjdbc/derby/active_record_patch.rb +0 -13
- data/lib/arjdbc/derby/adapter.rb +0 -521
- data/lib/arjdbc/derby/connection_methods.rb +0 -20
- data/lib/arjdbc/derby/schema_creation.rb +0 -15
- data/lib/arjdbc/derby.rb +0 -3
- data/lib/arjdbc/firebird/adapter.rb +0 -413
- data/lib/arjdbc/firebird/connection_methods.rb +0 -23
- data/lib/arjdbc/firebird.rb +0 -4
- data/lib/arjdbc/informix/adapter.rb +0 -139
- data/lib/arjdbc/informix/connection_methods.rb +0 -9
- data/lib/arjdbc/sybase/adapter.rb +0 -47
- data/lib/arjdbc/sybase.rb +0 -2
- data/lib/arjdbc/tasks/db2_database_tasks.rb +0 -104
- data/lib/arjdbc/tasks/derby_database_tasks.rb +0 -95
- data/src/java/arjdbc/derby/DerbyModule.java +0 -178
- data/src/java/arjdbc/derby/DerbyRubyJdbcConnection.java +0 -152
- data/src/java/arjdbc/firebird/FirebirdRubyJdbcConnection.java +0 -174
- data/src/java/arjdbc/informix/InformixRubyJdbcConnection.java +0 -75
@@ -1,174 +0,0 @@
|
|
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
|
-
}
|
@@ -1,75 +0,0 @@
|
|
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
|
-
}
|