Class | Sequel::JDBC::Derby::Dataset |
In: |
lib/sequel/adapters/jdbc/derby.rb
|
Parent: | JDBC::Dataset |
PAREN_CLOSE | = | Dataset::PAREN_CLOSE |
PAREN_OPEN | = | Dataset::PAREN_OPEN |
OFFSET | = | Dataset::OFFSET |
CAST_STRING_OPEN | = | "RTRIM(".freeze |
BITCOMP_OPEN | = | "((0 - ".freeze |
BITCOMP_CLOSE | = | ") - 1)".freeze |
BLOB_OPEN | = | "CAST(X'".freeze |
BLOB_CLOSE | = | "' AS BLOB)".freeze |
HSTAR | = | "H*".freeze |
TIME_FORMAT | = | "'%H:%M:%S'".freeze |
DEFAULT_FROM | = | " FROM sysibm.sysdummy1".freeze |
ROWS | = | " ROWS".freeze |
FETCH_FIRST | = | " FETCH FIRST ".freeze |
ROWS_ONLY | = | " ROWS ONLY".freeze |
BOOL_TRUE_OLD | = | '(1 = 1)'.freeze |
BOOL_FALSE_OLD | = | '(1 = 0)'.freeze |
BOOL_TRUE | = | 'TRUE'.freeze |
BOOL_FALSE | = | 'FALSE'.freeze |
SELECT_CLAUSE_METHODS | = | clause_methods(:select, %w'select distinct columns from join where group having compounds order limit lock') |
JAVA_SQL_CLOB | = | Java::JavaSQL::Clob |
DERBY_CLOB_METHOD | = | TYPE_TRANSLATOR_INSTANCE.method(:derby_clob) |
Derby doesn‘t support an expression between CASE and WHEN, so emulate it by using an equality statement for all of the conditions.
# File lib/sequel/adapters/jdbc/derby.rb, line 178 178: def case_expression_sql_append(sql, ce) 179: if ce.expression? 180: e = ce.expression 181: case_expression_sql_append(sql, ::Sequel::SQL::CaseExpression.new(ce.conditions.map{|c, r| [::Sequel::SQL::BooleanExpression.new('=''=', e, c), r]}, ce.default)) 182: else 183: super 184: end 185: 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 190 190: def cast_sql_append(sql, expr, type) 191: if type == String 192: sql << CAST_STRING_OPEN 193: super 194: sql << PAREN_CLOSE 195: else 196: super 197: end 198: end
Handle Derby specific LIKE, extract, and some bitwise compliment support.
# File lib/sequel/adapters/jdbc/derby.rb, line 201 201: def complex_expression_sql_append(sql, op, args) 202: case op 203: when :ILIKE 204: super(sql, :LIKE, [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1))]) 205: when "NOT ILIKE""NOT ILIKE" 206: super(sql, "NOT LIKE""NOT LIKE", [SQL::Function.new(:upper, args.at(0)), SQL::Function.new(:upper, args.at(1))]) 207: when :% 208: sql << complex_expression_arg_pairs(args){|a, b| "MOD(#{literal(a)}, #{literal(b)})"} 209: when :&, :|, :^, :<<, :>> 210: raise Error, "Derby doesn't support the #{op} operator" 211: when 'B~''B~' 212: sql << BITCOMP_OPEN 213: literal_append(sql, args.at(0)) 214: sql << BITCOMP_CLOSE 215: when :extract 216: sql << args.at(0).to_s << PAREN_OPEN 217: literal_append(sql, args.at(1)) 218: sql << PAREN_CLOSE 219: else 220: super 221: end 222: end