class Sequel::JDBC::Derby::Dataset
Public Instance Methods
Source
# File lib/sequel/adapters/jdbc/derby.rb 192 def case_expression_sql_append(sql, ce) 193 super(sql, ce.with_merged_expression) 194 end
Derby doesn’t support an expression between CASE and WHEN, so remove conditions.
Sequel::Dataset#case_expression_sql_append
Source
# File lib/sequel/adapters/jdbc/derby.rb 199 def cast_sql_append(sql, expr, type) 200 if type == String 201 sql << "RTRIM(" 202 super 203 sql << ')' 204 else 205 super 206 end 207 end
If the type is String, trim the extra spaces since CHAR is used instead of varchar. This can cause problems if you are casting a char/varchar to a string and the ending whitespace is important.
Sequel::Dataset#cast_sql_append
Source
# File lib/sequel/adapters/jdbc/derby.rb 209 def complex_expression_sql_append(sql, op, args) 210 case op 211 when :%, :'B~' 212 complex_expression_emulate_append(sql, op, args) 213 when :&, :|, :^, :<<, :>> 214 raise Error, "Derby doesn't support the #{op} operator" 215 when :** 216 sql << 'exp(' 217 literal_append(sql, args[1]) 218 sql << ' * ln(' 219 literal_append(sql, args[0]) 220 sql << "))" 221 when :extract 222 sql << args[0].to_s << '(' 223 literal_append(sql, args[1]) 224 sql << ')' 225 else 226 super 227 end 228 end
Sequel::Dataset#complex_expression_sql_append
Source
# File lib/sequel/adapters/jdbc/derby.rb 231 def supports_group_rollup? 232 true 233 end
Derby supports GROUP BY ROLLUP (but not CUBE)
Source
# File lib/sequel/adapters/jdbc/derby.rb 236 def supports_is_true? 237 false 238 end
Derby does not support IS TRUE.
Source
# File lib/sequel/adapters/jdbc/derby.rb 241 def supports_merge? 242 db.svn_version >= 1616546 243 end
Derby 10.11+ supports MERGE.
Source
# File lib/sequel/adapters/jdbc/derby.rb 246 def supports_multiple_column_in? 247 false 248 end
Derby does not support IN/NOT IN with multiple columns
Private Instance Methods
Source
# File lib/sequel/adapters/jdbc/derby.rb 252 def empty_from_sql 253 " FROM sysibm.sysdummy1" 254 end
Source
# File lib/sequel/adapters/jdbc/derby.rb 263 def insert_supports_empty_values? 264 false 265 end
Derby needs the standard workaround to insert all default values into a table with more than one column.
Source
# File lib/sequel/adapters/jdbc/derby.rb 257 def literal_blob_append(sql, v) 258 sql << "CAST(X'" << v.unpack("H*").first << "' AS BLOB)" 259 end
Derby needs a hex string casted to BLOB for blobs.
Source
# File lib/sequel/adapters/jdbc/derby.rb 268 def literal_false 269 if db.svn_version >= 1040133 270 'FALSE' 271 else 272 '(1 = 0)' 273 end 274 end
Newer Derby versions can use the FALSE literal, but older versions need an always false expression.
Source
# File lib/sequel/adapters/jdbc/derby.rb 277 def literal_sqltime(v) 278 v.strftime("'%H:%M:%S'") 279 end
Derby handles fractional seconds in timestamps, but not in times
Source
# File lib/sequel/adapters/jdbc/derby.rb 282 def literal_true 283 if db.svn_version >= 1040133 284 'TRUE' 285 else 286 '(1 = 1)' 287 end 288 end
Newer Derby versions can use the TRUE literal, but older versions need an always false expression.
Source
# File lib/sequel/adapters/jdbc/derby.rb 291 def multi_insert_sql_strategy 292 :values 293 end
Derby supports multiple rows for VALUES in INSERT.
Source
# File lib/sequel/adapters/jdbc/derby.rb 296 def native_function_name(emulated_function) 297 if emulated_function == :char_length 298 'length' 299 else 300 super 301 end 302 end
Emulate the char_length function with length
Sequel::Dataset#native_function_name
Source
# File lib/sequel/adapters/jdbc/derby.rb 305 def select_limit_sql(sql) 306 if o = @opts[:offset] 307 sql << " OFFSET " 308 literal_append(sql, o) 309 sql << " ROWS" 310 end 311 if l = @opts[:limit] 312 sql << " FETCH FIRST " 313 literal_append(sql, l) 314 sql << " ROWS ONLY" 315 end 316 end
Offset comes before limit in Derby