class Sequel::JDBC::Derby::Dataset
Public Instance Methods
Derby doesn't support an expression between CASE and WHEN, so remove conditions.
# File lib/sequel/adapters/jdbc/derby.rb, line 189 def case_expression_sql_append(sql, ce) super(sql, ce.with_merged_expression) 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.
# File lib/sequel/adapters/jdbc/derby.rb, line 196 def cast_sql_append(sql, expr, type) if type == String sql << "RTRIM(" super sql << ')' else super end end
# File lib/sequel/adapters/jdbc/derby.rb, line 206 def complex_expression_sql_append(sql, op, args) case op when :%, :'B~' complex_expression_emulate_append(sql, op, args) when :&, :|, :^, :<<, :>> raise Error, "Derby doesn't support the #{op} operator" when :** sql << 'exp(' literal_append(sql, args[1]) sql << ' * ln(' literal_append(sql, args[0]) sql << "))" when :extract sql << args[0].to_s << '(' literal_append(sql, args[1]) sql << ')' else super end end
Derby supports GROUP BY ROLLUP (but not CUBE)
# File lib/sequel/adapters/jdbc/derby.rb, line 228 def supports_group_rollup? true end
Derby does not support IS TRUE.
# File lib/sequel/adapters/jdbc/derby.rb, line 233 def supports_is_true? false end
Derby 10.11+ supports MERGE.
# File lib/sequel/adapters/jdbc/derby.rb, line 238 def supports_merge? db.svn_version >= 1616546 end
Derby does not support IN/NOT IN with multiple columns
# File lib/sequel/adapters/jdbc/derby.rb, line 243 def supports_multiple_column_in? false end
Private Instance Methods
# File lib/sequel/adapters/jdbc/derby.rb, line 249 def empty_from_sql " FROM sysibm.sysdummy1" end
Derby needs the standard workaround to insert all default values into a table with more than one column.
# File lib/sequel/adapters/jdbc/derby.rb, line 260 def insert_supports_empty_values? false end
Derby needs a hex string casted to BLOB for blobs.
# File lib/sequel/adapters/jdbc/derby.rb, line 254 def literal_blob_append(sql, v) sql << "CAST(X'" << v.unpack("H*").first << "' AS BLOB)" end
Newer Derby versions can use the FALSE literal, but older versions need an always false expression.
# File lib/sequel/adapters/jdbc/derby.rb, line 265 def literal_false if db.svn_version >= 1040133 'FALSE' else '(1 = 0)' end end
Derby handles fractional seconds in timestamps, but not in times
# File lib/sequel/adapters/jdbc/derby.rb, line 274 def literal_sqltime(v) v.strftime("'%H:%M:%S'") end
Newer Derby versions can use the TRUE literal, but older versions need an always false expression.
# File lib/sequel/adapters/jdbc/derby.rb, line 279 def literal_true if db.svn_version >= 1040133 'TRUE' else '(1 = 1)' end end
Derby supports multiple rows for VALUES in INSERT.
# File lib/sequel/adapters/jdbc/derby.rb, line 288 def multi_insert_sql_strategy :values end
Emulate the char_length function with length
# File lib/sequel/adapters/jdbc/derby.rb, line 293 def native_function_name(emulated_function) if emulated_function == :char_length 'length' else super end end
Offset comes before limit in Derby
# File lib/sequel/adapters/jdbc/derby.rb, line 302 def select_limit_sql(sql) if o = @opts[:offset] sql << " OFFSET " literal_append(sql, o) sql << " ROWS" end if l = @opts[:limit] sql << " FETCH FIRST " literal_append(sql, l) sql << " ROWS ONLY" end end