activerecord-jdbc-adapter 1.3.0.rc1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING.md +3 -5
- data/Gemfile +3 -5
- data/Gemfile.lock +1 -1
- data/History.md +30 -3
- data/README.md +14 -9
- data/gemfiles/rails23.gemfile +3 -0
- data/gemfiles/rails23.gemfile.lock +8 -0
- data/gemfiles/rails30.gemfile +3 -0
- data/gemfiles/rails30.gemfile.lock +11 -0
- data/gemfiles/rails31.gemfile +3 -0
- data/gemfiles/rails31.gemfile.lock +8 -0
- data/gemfiles/rails32.gemfile +3 -0
- data/gemfiles/rails32.gemfile.lock +11 -0
- data/gemfiles/rails40.gemfile +3 -0
- data/gemfiles/rails40.gemfile.lock +6 -0
- data/lib/arjdbc/db2/adapter.rb +39 -23
- data/lib/arjdbc/db2/column.rb +3 -3
- data/lib/arjdbc/derby/adapter.rb +45 -0
- data/lib/arjdbc/firebird/adapter.rb +38 -36
- data/lib/arjdbc/h2/adapter.rb +1 -1
- data/lib/arjdbc/hsqldb/adapter.rb +1 -0
- data/lib/arjdbc/hsqldb/explain_support.rb +6 -6
- data/lib/arjdbc/jdbc/adapter.rb +80 -39
- data/lib/arjdbc/jdbc/adapter_java.jar +0 -0
- data/lib/arjdbc/jdbc/serialized_attributes_helper.rb +3 -21
- data/lib/arjdbc/mssql/adapter.rb +41 -18
- data/lib/arjdbc/mssql/column.rb +3 -8
- data/lib/arjdbc/mssql/explain_support.rb +1 -1
- data/lib/arjdbc/mysql/adapter.rb +19 -9
- data/lib/arjdbc/mysql/column.rb +1 -1
- data/lib/arjdbc/mysql/connection_methods.rb +1 -0
- data/lib/arjdbc/mysql/explain_support.rb +2 -1
- data/lib/arjdbc/oracle/adapter.rb +42 -26
- data/lib/arjdbc/oracle/column.rb +1 -1
- data/lib/arjdbc/postgresql/adapter.rb +13 -4
- data/lib/arjdbc/sqlite3/adapter.rb +2 -0
- data/lib/arjdbc/tasks/oracle/enhanced_structure_dump.rb +5 -5
- data/lib/arjdbc/util/serialized_attributes.rb +87 -0
- data/lib/arjdbc/version.rb +1 -1
- data/rakelib/02-test.rake +1 -1
- data/rakelib/db.rake +1 -1
- data/src/java/arjdbc/db2/DB2RubyJdbcConnection.java +2 -2
- data/src/java/arjdbc/derby/DerbyModule.java +26 -173
- data/src/java/arjdbc/h2/H2Module.java +1 -0
- data/src/java/arjdbc/h2/H2RubyJdbcConnection.java +1 -2
- data/src/java/arjdbc/hsqldb/HSQLDBModule.java +10 -9
- data/src/java/arjdbc/jdbc/AdapterJavaService.java +3 -3
- data/src/java/arjdbc/jdbc/JdbcConnectionFactory.java +4 -3
- data/src/java/arjdbc/jdbc/RubyJdbcConnection.java +189 -70
- data/src/java/arjdbc/jdbc/SQLBlock.java +4 -4
- data/src/java/arjdbc/mssql/MSSQLRubyJdbcConnection.java +6 -7
- data/src/java/arjdbc/mysql/MySQLModule.java +1 -0
- data/src/java/arjdbc/mysql/MySQLRubyJdbcConnection.java +14 -9
- data/src/java/arjdbc/oracle/OracleRubyJdbcConnection.java +19 -3
- data/src/java/arjdbc/postgresql/PostgreSQLRubyJdbcConnection.java +305 -11
- data/src/java/arjdbc/sqlite3/SQLite3RubyJdbcConnection.java +3 -3
- metadata +6 -5
@@ -44,15 +44,15 @@ module ActiveRecord #:nodoc:
|
|
44
44
|
|
45
45
|
def structure_dump_column(column) #:nodoc:
|
46
46
|
col = "\"#{column['column_name']}\" #{column['data_type']}"
|
47
|
-
if column['data_type'] =='NUMBER'
|
47
|
+
if column['data_type'] =='NUMBER' && ! column['data_precision'].blank?
|
48
48
|
col << "(#{column['data_precision'].to_i}"
|
49
|
-
col << ",#{column['data_scale'].to_i}"
|
49
|
+
col << ",#{column['data_scale'].to_i}" unless column['data_scale'].blank?
|
50
50
|
col << ')'
|
51
51
|
elsif column['data_type'].include?('CHAR')
|
52
52
|
length = column['char_used'] == 'C' ? column['char_length'].to_i : column['data_length'].to_i
|
53
53
|
col << "(#{length})"
|
54
54
|
end
|
55
|
-
col << " DEFAULT #{column['data_default']}"
|
55
|
+
col << " DEFAULT #{column['data_default']}" unless column['data_default'].blank?
|
56
56
|
col << ' NOT NULL' if column['nullable'] == 'N'
|
57
57
|
col
|
58
58
|
end
|
@@ -60,9 +60,9 @@ module ActiveRecord #:nodoc:
|
|
60
60
|
def structure_dump_virtual_column(column, data_default) #:nodoc:
|
61
61
|
data_default = data_default.gsub(/"/, '')
|
62
62
|
col = "\"#{column['column_name']}\" #{column['data_type']}"
|
63
|
-
if column['data_type'] =='NUMBER'
|
63
|
+
if column['data_type'] =='NUMBER' && ! column['data_precision'].blank?
|
64
64
|
col << "(#{column['data_precision'].to_i}"
|
65
|
-
col << ",#{column['data_scale'].to_i}"
|
65
|
+
col << ",#{column['data_scale'].to_i}" unless column['data_scale'].blank?
|
66
66
|
col << ')'
|
67
67
|
elsif column['data_type'].include?('CHAR')
|
68
68
|
length = column['char_used'] == 'C' ? column['char_length'].to_i : column['data_length'].to_i
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module ArJdbc
|
2
|
+
module Util
|
3
|
+
# Gets included into `ActiveRecord::Base` to support sending LOB values
|
4
|
+
# in a separate update SQL statement for DB adapters that need this.
|
5
|
+
module SerializedAttributes
|
6
|
+
|
7
|
+
# protected
|
8
|
+
|
9
|
+
def update_lob_columns
|
10
|
+
klass = self.class
|
11
|
+
return unless type = klass.lob_type # e.g. /blob/i
|
12
|
+
connection = klass.connection
|
13
|
+
if connection.respond_to?(:update_lob_values?)
|
14
|
+
return false unless connection.update_lob_values?
|
15
|
+
end
|
16
|
+
klass.columns.each do |column|
|
17
|
+
next if column.sql_type !~ type
|
18
|
+
next if ( value = dump_column_value(column) ).nil?
|
19
|
+
if connection.respond_to?(:update_lob_value?)
|
20
|
+
next unless connection.update_lob_value?(value, column)
|
21
|
+
end
|
22
|
+
connection.update_lob_value(self, column, value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def dump_column_value(column)
|
29
|
+
SerializedAttributes.dump_column_value(self, column)
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.dump_column_value(record, column)
|
33
|
+
value = record[ name = column.name.to_s ]
|
34
|
+
if record.class.respond_to?(:serialized_attributes)
|
35
|
+
if coder = record.class.serialized_attributes[name]
|
36
|
+
value = coder.respond_to?(:dump) ? coder.dump(value) : value.to_yaml
|
37
|
+
end
|
38
|
+
else
|
39
|
+
if record.respond_to?(:unserializable_attribute?)
|
40
|
+
value = value.to_yaml if record.unserializable_attribute?(name, column)
|
41
|
+
else
|
42
|
+
value = value.to_yaml if value.is_a?(Hash)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
value
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.setup(lob_type = nil, after_save_alias = nil)
|
49
|
+
ActiveRecord::Base.send :include, self # include SerializedAttributes
|
50
|
+
ActiveRecord::Base.lob_type = lob_type unless lob_type.nil?
|
51
|
+
if after_save_alias
|
52
|
+
ActiveRecord::Base.class_eval do
|
53
|
+
alias_method after_save_alias, 'update_lob_columns'
|
54
|
+
end
|
55
|
+
ActiveRecord::Base.after_save after_save_alias
|
56
|
+
else
|
57
|
+
ActiveRecord::Base.after_save 'update_lob_columns'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.included(base)
|
62
|
+
base.extend ClassMethods
|
63
|
+
end
|
64
|
+
|
65
|
+
module ClassMethods
|
66
|
+
|
67
|
+
def lob_type
|
68
|
+
@lob_type ||= begin
|
69
|
+
if superclass.respond_to?(:lob_type)
|
70
|
+
superclass.lob_type
|
71
|
+
else
|
72
|
+
/blob|clob/i
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def lob_type=(type)
|
78
|
+
@lob_type = type
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
# @private only due backwards compatibility
|
86
|
+
SerializedAttributesHelper = Util::SerializedAttributes
|
87
|
+
end
|
data/lib/arjdbc/version.rb
CHANGED
data/rakelib/02-test.rake
CHANGED
@@ -82,7 +82,7 @@ test_task_for :PostgreSQL, :prereqs => 'db:postgresql', :driver => 'postgres'
|
|
82
82
|
task :test_postgres => :test_postgresql # alias
|
83
83
|
task :test_pgsql => :test_postgresql # alias
|
84
84
|
test_task_for :SQLite3
|
85
|
-
test_task_for :
|
85
|
+
test_task_for :Firebird
|
86
86
|
|
87
87
|
# ensure driver for these DBs is on your class-path
|
88
88
|
[ :Oracle, :DB2, :Informix, :CacheDB ].each do |adapter|
|
data/rakelib/db.rake
CHANGED
@@ -7,7 +7,7 @@ namespace :db do
|
|
7
7
|
load 'test/db/mysql_config.rb' # rescue nil
|
8
8
|
script = sql_script <<-SQL, 'mysql'
|
9
9
|
DROP DATABASE IF EXISTS `#{MYSQL_CONFIG[:database]}`;
|
10
|
-
CREATE DATABASE `#{MYSQL_CONFIG[:database]}` DEFAULT CHARACTER SET `utf8`;
|
10
|
+
CREATE DATABASE `#{MYSQL_CONFIG[:database]}` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_general_ci`;
|
11
11
|
GRANT ALL PRIVILEGES ON `#{MYSQL_CONFIG[:database]}`.* TO #{MYSQL_CONFIG[:username]}@localhost;
|
12
12
|
GRANT ALL PRIVILEGES ON `test\_%`.* TO #{MYSQL_CONFIG[:username]}@localhost;
|
13
13
|
SET PASSWORD FOR #{MYSQL_CONFIG[:username]}@localhost = PASSWORD('#{MYSQL_CONFIG[:password]}');
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Copyright (c) 2012-2013 Karol Bucek <self@kares.org>
|
3
3
|
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
4
4
|
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
5
5
|
* Copyright (c) 2008-2009 Thomas E Enebo <enebo@acm.org>
|
@@ -1,4 +1,5 @@
|
|
1
1
|
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Copyright (c) 2012-2013 Karol Bucek <self@kares.org>
|
2
3
|
* Copyright (c) 2006-2011 Nick Sieger <nick@nicksieger.com>
|
3
4
|
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
4
5
|
*
|
@@ -29,7 +30,6 @@ import static arjdbc.util.QuotingUtils.BYTES_1;
|
|
29
30
|
import static arjdbc.util.QuotingUtils.BYTES_SINGLE_Q_x2;
|
30
31
|
|
31
32
|
import org.jruby.Ruby;
|
32
|
-
import org.jruby.RubyBoolean;
|
33
33
|
import org.jruby.RubyModule;
|
34
34
|
import org.jruby.RubyString;
|
35
35
|
import org.jruby.anno.JRubyMethod;
|
@@ -97,150 +97,10 @@ public class DerbyModule {
|
|
97
97
|
|
98
98
|
}
|
99
99
|
|
100
|
-
@JRubyMethod(name = "
|
101
|
-
public static IRubyObject
|
102
|
-
final IRubyObject self, final IRubyObject
|
103
|
-
|
104
|
-
IRubyObject value = args[0];
|
105
|
-
if ( args.length > 1 ) {
|
106
|
-
final IRubyObject column = args[1];
|
107
|
-
final String columnType = column.isNil() ? "" : column.callMethod(context, "type").toString();
|
108
|
-
// intercept and change value, maybe, if the column type is :text or :string
|
109
|
-
if ( columnType.equals("text") || columnType.equals("string") ) {
|
110
|
-
value = toRubyStringForTextColumn(context, runtime, self, value);
|
111
|
-
}
|
112
|
-
|
113
|
-
if ( value instanceof RubyString ) {
|
114
|
-
if ( columnType.equals("string") ) {
|
115
|
-
return quoteString(runtime, "'", value, "'");
|
116
|
-
}
|
117
|
-
if ( columnType.equals("text") ) {
|
118
|
-
return quoteString(runtime, "CAST('", value, "' AS CLOB)");
|
119
|
-
}
|
120
|
-
if ( columnType.equals("binary") ) {
|
121
|
-
return quoteStringHex(runtime, "CAST(X'", value, "' AS BLOB)");
|
122
|
-
}
|
123
|
-
if ( columnType.equals("xml") ) {
|
124
|
-
return quoteString(runtime, "XMLPARSE(DOCUMENT '", value, "' PRESERVE WHITESPACE)");
|
125
|
-
}
|
126
|
-
// column type :integer or other numeric or date version
|
127
|
-
return isDigitsOnly(value) ? value : quoteDefault(context, runtime, self, value, column, columnType);
|
128
|
-
}
|
129
|
-
|
130
|
-
final String metaClass = value.getMetaClass().getName();
|
131
|
-
if ( metaClass.equals("Float") || metaClass.equals("Fixnum") || metaClass.equals("Bignum") ) {
|
132
|
-
if ( columnType.equals("string") ) {
|
133
|
-
return quoteString(runtime, "'", RubyString.objAsString(context, value), "'");
|
134
|
-
}
|
135
|
-
}
|
136
|
-
}
|
137
|
-
return quoteDefault(context, runtime, self, value, runtime.getNil(), null);
|
138
|
-
}
|
139
|
-
|
140
|
-
private static IRubyObject quoted_date_OR_to_yaml(final ThreadContext context,
|
141
|
-
final Ruby runtime, final IRubyObject self, final IRubyObject value) {
|
142
|
-
|
143
|
-
if ( value.callMethod(context, "acts_like?", runtime.newSymbol("date")).isTrue()
|
144
|
-
|| value.callMethod(context, "acts_like?", runtime.newSymbol("time")).isTrue() ) {
|
145
|
-
return self.callMethod(context, "quoted_date", value);
|
146
|
-
}
|
147
|
-
else {
|
148
|
-
return value.callMethod(context, "to_yaml");
|
149
|
-
}
|
150
|
-
}
|
151
|
-
|
152
|
-
/*
|
153
|
-
* Derby is not permissive like MySql. Try and send an Integer to a CLOB or
|
154
|
-
* VARCHAR column and Derby will vomit.
|
155
|
-
* This method turns non stringy things into strings.
|
156
|
-
*/
|
157
|
-
private static IRubyObject toRubyStringForTextColumn(
|
158
|
-
final ThreadContext context, final Ruby runtime, final IRubyObject self,
|
159
|
-
final IRubyObject value) {
|
160
|
-
|
161
|
-
if ( value instanceof RubyString || value.isNil() || isMultibyteChars(runtime, value) ) {
|
162
|
-
return value;
|
163
|
-
}
|
164
|
-
|
165
|
-
if ( value instanceof RubyBoolean ) return quoteBoolean(runtime, value);
|
166
|
-
|
167
|
-
final String className = value.getMetaClass().getName();
|
168
|
-
if ( className.equals("Float") || className.equals("Fixnum") || className.equals("Bignum") ) {
|
169
|
-
return RubyString.objAsString(context, value);
|
170
|
-
}
|
171
|
-
if ( className.equals("BigDecimal") ) {
|
172
|
-
return value.callMethod(context, "to_s", runtime.newString("F"));
|
173
|
-
}
|
174
|
-
|
175
|
-
return quoted_date_OR_to_yaml(context, runtime, self, value);
|
176
|
-
}
|
177
|
-
|
178
|
-
private final static ByteList NULL = new ByteList("NULL".getBytes(), false);
|
179
|
-
|
180
|
-
private static IRubyObject quoteDefault(final ThreadContext context,
|
181
|
-
final Ruby runtime, final IRubyObject self,
|
182
|
-
final IRubyObject value, final IRubyObject column, final String columnType) {
|
183
|
-
|
184
|
-
if ( value.respondsTo("quoted_id") ) {
|
185
|
-
return value.callMethod(context, "quoted_id");
|
186
|
-
}
|
187
|
-
|
188
|
-
if ( value.isNil() ) {
|
189
|
-
return runtime.newString(NULL);
|
190
|
-
}
|
191
|
-
if ( value instanceof RubyBoolean ) {
|
192
|
-
if ( columnType == (Object) "integer" ) return quoteBoolean(runtime, value);
|
193
|
-
return self.callMethod(context, value.isTrue() ? "quoted_true" : "quoted_false");
|
194
|
-
}
|
195
|
-
if ( value instanceof RubyString || isMultibyteChars(runtime, value) ) {
|
196
|
-
|
197
|
-
final RubyString strValue = RubyString.objAsString(context, value);
|
198
|
-
|
199
|
-
if ( columnType == (Object) "binary" && column.getType().respondsTo("string_to_binary") ) {
|
200
|
-
IRubyObject str = column.getType().callMethod(context, "string_to_binary", strValue);
|
201
|
-
return quoteString(runtime, "'", str, "'");
|
202
|
-
}
|
203
|
-
|
204
|
-
if ( columnType == (Object) "integer" ) {
|
205
|
-
return RubyString.objAsString( context, strValue.callMethod(context, "to_i") );
|
206
|
-
}
|
207
|
-
|
208
|
-
if ( columnType == (Object) "float" ) {
|
209
|
-
return RubyString.objAsString( context, strValue.callMethod(context, "to_f") );
|
210
|
-
}
|
211
|
-
|
212
|
-
return quoteString(runtime, "'", strValue, "'");
|
213
|
-
}
|
214
|
-
|
215
|
-
final String className = value.getMetaClass().getName();
|
216
|
-
if ( className.equals("Float") || className.equals("Fixnum") || className.equals("Bignum") ) {
|
217
|
-
return RubyString.objAsString(context, value);
|
218
|
-
}
|
219
|
-
if ( className.equals("BigDecimal") ) {
|
220
|
-
return value.callMethod(context, "to_s", runtime.newString("F"));
|
221
|
-
}
|
222
|
-
|
223
|
-
IRubyObject strValue = quoted_date_OR_to_yaml(context, runtime, self, value);
|
224
|
-
return quoteString(runtime, "'", strValue, "'");
|
225
|
-
}
|
226
|
-
|
227
|
-
private static IRubyObject quoteString(final Ruby runtime,
|
228
|
-
final String before, final IRubyObject string, final String after) {
|
229
|
-
|
230
|
-
final ByteList input = ((RubyString) string).getByteList();
|
231
|
-
final ByteList output = new ByteList(before.getBytes(), input.getEncoding());
|
232
|
-
final byte[] inputBytes = input.unsafeBytes();
|
233
|
-
|
234
|
-
for(int i = input.getBegin(); i< input.getBegin() + input.getRealSize(); i++) {
|
235
|
-
switch ( inputBytes[i] ) {
|
236
|
-
case '\'': output.append(inputBytes[i]); // FALLTHROUGH
|
237
|
-
default: output.append(inputBytes[i]);
|
238
|
-
}
|
239
|
-
|
240
|
-
}
|
241
|
-
|
242
|
-
output.append(after.getBytes());
|
243
|
-
return runtime.newString(output);
|
100
|
+
@JRubyMethod(name = "quote_binary", required = 1)
|
101
|
+
public static IRubyObject quote_binary(final ThreadContext context,
|
102
|
+
final IRubyObject self, final IRubyObject string) {
|
103
|
+
return quoteStringHex(context.getRuntime(), "", string, "");
|
244
104
|
}
|
245
105
|
|
246
106
|
private final static byte[] HEX = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
@@ -249,44 +109,35 @@ public class DerbyModule {
|
|
249
109
|
final String before, final IRubyObject string, final String after) {
|
250
110
|
|
251
111
|
final ByteList input = ((RubyString) string).getByteList();
|
252
|
-
final
|
112
|
+
final int size = input.getRealSize();
|
113
|
+
final ByteList output = new ByteList( before.length() + size * 2 + after.length() );
|
114
|
+
output.append( before.getBytes() );
|
115
|
+
|
253
116
|
final byte[] inputBytes = input.unsafeBytes();
|
254
117
|
|
255
118
|
int written = 0;
|
256
|
-
for(int i = input.getBegin(); i< input.getBegin() +
|
257
|
-
byte
|
258
|
-
byte
|
259
|
-
byte
|
260
|
-
output.append(
|
261
|
-
output.append(lower);
|
119
|
+
for (int i = input.getBegin(); i < input.getBegin() + size; i++) {
|
120
|
+
final byte b = inputBytes[i];
|
121
|
+
byte h = HEX[ ( ((char) b) >> 4 ) % 16 ];
|
122
|
+
byte l = HEX[ ( (char) b ) % 16 ];
|
123
|
+
output.append(h).append(l);
|
262
124
|
written += 2;
|
263
|
-
if (written >= 16334) { // max hex length = 16334
|
125
|
+
if ( written >= 16334 ) { // max hex length = 16334
|
264
126
|
output.append("'||X'".getBytes());
|
265
127
|
written = 0;
|
266
128
|
}
|
267
129
|
}
|
268
130
|
|
269
|
-
output.append(after.getBytes());
|
131
|
+
output.append( after.getBytes() );
|
270
132
|
return RubyString.newStringShared(runtime, output);
|
271
133
|
}
|
272
134
|
|
273
|
-
private static boolean isDigitsOnly(final IRubyObject string) {
|
274
|
-
final ByteList input = ((RubyString) string).getByteList();
|
275
|
-
final byte[] inputBytes = input.unsafeBytes();
|
276
|
-
for ( int i = input.getBegin(); i< input.getBegin() + input.getRealSize(); i++ ) {
|
277
|
-
if ( inputBytes[i] < '0' || inputBytes[i] > '9' ) {
|
278
|
-
return false;
|
279
|
-
}
|
280
|
-
}
|
281
|
-
return true;
|
282
|
-
}
|
283
|
-
|
284
|
-
private static boolean isMultibyteChars(final Ruby runtime, final IRubyObject value) {
|
285
|
-
return getMultibyteChars(runtime).isInstance(value);
|
286
|
-
}
|
287
|
-
|
288
135
|
@JRubyMethod(name = "quote_string", required = 1)
|
289
136
|
public static IRubyObject quote_string(final IRubyObject self, IRubyObject string) {
|
137
|
+
if ( ! ( string instanceof RubyString ) ) {
|
138
|
+
string = string.asString(); // e.g. Multibyte::Chars
|
139
|
+
}
|
140
|
+
|
290
141
|
ByteList bytes = ((RubyString) string).getByteList();
|
291
142
|
|
292
143
|
boolean replacement = false;
|
@@ -310,15 +161,13 @@ public class DerbyModule {
|
|
310
161
|
|
311
162
|
@JRubyMethod(name = "quoted_true", required = 0, frame = false)
|
312
163
|
public static IRubyObject quoted_true(
|
313
|
-
|
314
|
-
final IRubyObject self) {
|
164
|
+
final ThreadContext context, final IRubyObject self) {
|
315
165
|
return RubyString.newString(context.getRuntime(), BYTES_1);
|
316
166
|
}
|
317
167
|
|
318
168
|
@JRubyMethod(name = "quoted_false", required = 0, frame = false)
|
319
169
|
public static IRubyObject quoted_false(
|
320
|
-
|
321
|
-
final IRubyObject self) {
|
170
|
+
final ThreadContext context, final IRubyObject self) {
|
322
171
|
return RubyString.newString(context.getRuntime(), BYTES_0);
|
323
172
|
}
|
324
173
|
|
@@ -326,6 +175,10 @@ public class DerbyModule {
|
|
326
175
|
return value.isTrue() ? runtime.newString(BYTES_1) : runtime.newString(BYTES_0);
|
327
176
|
}
|
328
177
|
|
178
|
+
private static boolean isMultibyteChars(final Ruby runtime, final IRubyObject value) {
|
179
|
+
return getMultibyteChars(runtime).isInstance(value);
|
180
|
+
}
|
181
|
+
|
329
182
|
private static RubyModule getMultibyteChars(final Ruby runtime) {
|
330
183
|
return (RubyModule) ((RubyModule) runtime.getModule("ActiveSupport").
|
331
184
|
getConstant("Multibyte")).getConstantAt("Chars");
|
@@ -1,4 +1,5 @@
|
|
1
1
|
/***** BEGIN LICENSE BLOCK *****
|
2
|
+
* Copyright (c) 2012-2013 Karol Bucek <self@kares.org>
|
2
3
|
* Copyright (c) 2006-2010 Nick Sieger <nick@nicksieger.com>
|
3
4
|
* Copyright (c) 2006-2007 Ola Bini <ola.bini@gmail.com>
|
4
5
|
*
|
@@ -35,33 +36,33 @@ import org.jruby.runtime.ThreadContext;
|
|
35
36
|
import org.jruby.runtime.builtin.IRubyObject;
|
36
37
|
|
37
38
|
public class HSQLDBModule {
|
38
|
-
|
39
|
+
|
39
40
|
public static RubyModule load(final RubyModule arJdbc) {
|
40
41
|
RubyModule hsqldb = arJdbc.defineModuleUnder("HSQLDB");
|
41
42
|
hsqldb.defineAnnotatedMethods( HSQLDBModule.class );
|
42
43
|
return hsqldb;
|
43
44
|
}
|
44
|
-
|
45
|
+
|
45
46
|
@JRubyMethod(name = "quote_string", required = 1, frame = false)
|
46
47
|
public static IRubyObject quote_string(
|
47
|
-
final ThreadContext context,
|
48
|
-
final IRubyObject self,
|
48
|
+
final ThreadContext context,
|
49
|
+
final IRubyObject self,
|
49
50
|
final IRubyObject string) {
|
50
51
|
return quoteSingleQuotesWithFallback(context, string);
|
51
52
|
}
|
52
|
-
|
53
|
+
|
53
54
|
@JRubyMethod(name = "quoted_true", required = 0, frame = false)
|
54
55
|
public static IRubyObject quoted_true(
|
55
|
-
final ThreadContext context,
|
56
|
+
final ThreadContext context,
|
56
57
|
final IRubyObject self) {
|
57
58
|
return RubyString.newString(context.getRuntime(), BYTES_1);
|
58
59
|
}
|
59
|
-
|
60
|
+
|
60
61
|
@JRubyMethod(name = "quoted_false", required = 0, frame = false)
|
61
62
|
public static IRubyObject quoted_false(
|
62
|
-
final ThreadContext context,
|
63
|
+
final ThreadContext context,
|
63
64
|
final IRubyObject self) {
|
64
65
|
return RubyString.newString(context.getRuntime(), BYTES_0);
|
65
66
|
}
|
66
|
-
|
67
|
+
|
67
68
|
}
|