class Sequel::JDBC::Derby::Dataset
Public Instance Methods
Source
# File lib/sequel/adapters/jdbc/derby.rb 190 def case_expression_sql_append(sql, ce) 191 super(sql, ce.with_merged_expression) 192 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 197 def cast_sql_append(sql, expr, type) 198 if type == String 199 sql << "RTRIM(" 200 super 201 sql << ')' 202 else 203 super 204 end 205 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 207 def complex_expression_sql_append(sql, op, args) 208 case op 209 when :%, :'B~' 210 complex_expression_emulate_append(sql, op, args) 211 when :&, :|, :^, :<<, :>> 212 raise Error, "Derby doesn't support the #{op} operator" 213 when :** 214 sql << 'exp(' 215 literal_append(sql, args[1]) 216 sql << ' * ln(' 217 literal_append(sql, args[0]) 218 sql << "))" 219 when :extract 220 sql << args[0].to_s << '(' 221 literal_append(sql, args[1]) 222 sql << ')' 223 else 224 super 225 end 226 end
Sequel::Dataset#complex_expression_sql_append
Source
# File lib/sequel/adapters/jdbc/derby.rb 229 def supports_group_rollup? 230 true 231 end
Derby supports GROUP BY ROLLUP (but not CUBE)
Source
# File lib/sequel/adapters/jdbc/derby.rb 234 def supports_is_true? 235 false 236 end
Derby does not support IS TRUE.
Source
# File lib/sequel/adapters/jdbc/derby.rb 239 def supports_merge? 240 db.svn_version >= 1616546 241 end
Derby 10.11+ supports MERGE.
Source
# File lib/sequel/adapters/jdbc/derby.rb 244 def supports_multiple_column_in? 245 false 246 end
Derby does not support IN/NOT IN with multiple columns
Private Instance Methods
Source
# File lib/sequel/adapters/jdbc/derby.rb 250 def empty_from_sql 251 " FROM sysibm.sysdummy1" 252 end
Source
# File lib/sequel/adapters/jdbc/derby.rb 261 def insert_supports_empty_values? 262 false 263 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 255 def literal_blob_append(sql, v) 256 sql << "CAST(X'" << v.unpack("H*").first << "' AS BLOB)" 257 end
Derby needs a hex string casted to BLOB for blobs.
Source
# File lib/sequel/adapters/jdbc/derby.rb 266 def literal_false 267 if db.svn_version >= 1040133 268 'FALSE' 269 else 270 '(1 = 0)' 271 end 272 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 275 def literal_sqltime(v) 276 v.strftime("'%H:%M:%S'") 277 end
Derby handles fractional seconds in timestamps, but not in times
Source
# File lib/sequel/adapters/jdbc/derby.rb 280 def literal_true 281 if db.svn_version >= 1040133 282 'TRUE' 283 else 284 '(1 = 1)' 285 end 286 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 289 def multi_insert_sql_strategy 290 :values 291 end
Derby supports multiple rows for VALUES in INSERT.
Source
# File lib/sequel/adapters/jdbc/derby.rb 294 def native_function_name(emulated_function) 295 if emulated_function == :char_length 296 'length' 297 else 298 super 299 end 300 end
Emulate the char_length function with length
Sequel::Dataset#native_function_name
Source
# File lib/sequel/adapters/jdbc/derby.rb 303 def select_limit_sql(sql) 304 if o = @opts[:offset] 305 sql << " OFFSET " 306 literal_append(sql, o) 307 sql << " ROWS" 308 end 309 if l = @opts[:limit] 310 sql << " FETCH FIRST " 311 literal_append(sql, l) 312 sql << " ROWS ONLY" 313 end 314 end
Offset comes before limit in Derby